Monday 18 March 2019

Helpful URL for study

https://docs.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2017

https://docs.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2017

https://www.c-sharpcorner.com/article/deply-of-a-angular-application-on-iis/


// Generic concept

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/





https://signalrchat20190307055019.azurewebsites.net/



https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-2.2&tabs=visual-studio




https://docs.microsoft.com/en-us/learn/modules/host-a-web-app-with-azure-app-service/



https://www.c-sharpcorner.com/article/deploy-asp-net-mvc-application-to-windows-azure/



https://www.codeproject.com/Tips/1044950/How-to-Publish-ASP-NET-MVC-Web-Application-to-Azur



https://www.aspsnippets.com/Articles/ASPNet-MVC-Send-user-Confirmation-email-after-Registration-with-Activation-Link.aspx



http://www.dotnetawesome.com/2017/04/complete-login-registration-system-asp-mvc.html



https://docs.microsoft.com/en-us/aspnet/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity







Note: Clinic Management System

https://www.c-sharpcorner.com/article/clinic-management-project-using-asp-net-mvc-5/



run : enable-migrations
add-migration "InitialDb"
update-database





https://docs.microsoft.com/en-us/aspnet/aspnet/overview/developing-apps-with-windows-azure/building-real-world-cloud-apps-with-windows-azure/web-development-best-practices#async

https://www.c-sharpcorner.com/UploadFile/4d9083/project-gymone-demo-project-in-mvc/



http://bitoftech.net/2014/06/09/angularjs-token-authentication-using-asp-net-web-api-2-owin-asp-net-identity/



http://bitoftech.net/2014/08/11/asp-net-web-api-2-external-logins-social-logins-facebook-google-angularjs-app/



https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/real-time-web-applications-with-signalr



https://www.dotnetcurry.com/angularjs/1062/website-using-angularjs-aspnet-webapi

https://github.com/aspnet/Docs/tree/master/aspnetcore/data/ef-mvc/intro/samples/cu-final

https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-dotnet

https://github.com/Vimal123/Angular5DemoAdmin



https://www.codeproject.com/articles/36511/task-management-system

Thursday 14 March 2019

custom exception on your business logic layer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Utilities.ExceptionHandler
{
    public class CustomRule
    {
        [JsonConstructor]
        public CustomRule(string name, string description)
        {
            Name = name;
            Description = description;
            ErrorCategory = CustomRuleEnum.Validation.ToStringValue();
        }

        public CustomRule(string errorCategory, string name, string description)
        {
            ErrorCategory = errorCategory;
            Name = name;
            Description = description;
        }



        public string ErrorCategory { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
    }


    public enum CustomRuleEnum
    {
        [StringValue("General")]
        General,

        // Use this for pre-processing checks; e.g. before any database activity
        [StringValue("Validation")]
        Validation,

        // Use this for any post checks cause from a data related issue after trying to process a request
        [StringValue("Data")]
        Data
    }

    public class StringValueAttribute : Attribute
    {
        public StringValueAttribute(string value)
        {
            Value = value;
        }

        public string Value { get; protected set; }
    }


   public static class ExtensionHelper
    {
        /// <summary>
        ///     https://cisart.wordpress.com/2013/09/11/string-value-attribute-for-enums/
        ///     Example Enum to String:
        ///     TestEnum test = TestEnum.Value2;
        ///     string str = test.ToStringValue();
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string ToStringValue(this Enum value)
        {
            var attributes =
                (StringValueAttribute[])
                    value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(StringValueAttribute), false);
            return ((attributes.Length > 0)) ? attributes[0].Value : value.ToString();
        }
    }

    public class CustomValidationException : System.Exception
    {
        public IEnumerable<CustomRule> CustomRules;

        public CustomValidationException(string message, IEnumerable<CustomRule> customRules)
                : base(message)
        {
            CustomRules = customRules;
        }

        public CustomValidationException(string message)
            : base(message)
        {
        }

        public CustomValidationException(string message, System.Exception inner)
            : base(message, inner)
        {
        }
    }
}

// apply on class

public bool IsValid()
        {
            return !CustomRules().Any();
        }

        public IEnumerable<CustomRule> CustomRules()
        {
            if (string.IsNullOrWhiteSpace(Name))
                yield return new CustomRule("MissingName", "Test name is required.");

        }

// apply on service method
 // validation
                if (!dbTest.IsValid())
                    throw new CustomValidationException("Validation Error", dbTest.CustomRules());