public IResult CreateUser(UserViewModel userViewModel)
        {
            var result = new Result
            {
                Operation = Operation.Create,
                Status    = Status.Success
            };

            try
            {
                var duplicateUserName = _userRepository.GetFirstOrDefault(x => (x.IsActive && !x.IsDeleted) && (x.UserName == userViewModel.UserName));
                var duplicateEmail    = _userRepository.GetFirstOrDefault(x => (x.IsActive && !x.IsDeleted) && (x.Email == userViewModel.Email));
                if (duplicateUserName != null)
                {
                    result.Status  = Status.Fail;
                    result.Message = UserStatusNotification.DuplicateUserName;
                    result.Body    = null;
                    return(result);
                }
                else if (duplicateEmail != null)
                {
                    result.Status  = Status.Fail;
                    result.Message = UserStatusNotification.DuplicateEmail;
                    result.Body    = null;
                    return(result);
                }
                else
                {
                    var userModel = new Users();
                    userModel.MapFromViewModel(userViewModel, (ClaimsIdentity)_principal.Identity);

                    UserRoles userRole = new UserRoles();
                    userRole.RoleId = userViewModel.RoleId;
                    userRole.Role   = _roleRepository.GetByID(userViewModel.RoleId);
                    userRole.MapAuditColumns((ClaimsIdentity)_principal.Identity);
                    _userRepository.CreateUser(userModel, userRole);
                    userViewModel.Password = GenericHelper.DecryptPassword(userViewModel.Password);
                    if (userModel.UserId != Guid.Empty)
                    {
                        MailDetailModel mailDetail = new MailDetailModel();
                        mailDetail.EmailId     = userModel.Email;
                        mailDetail.Subject     = "Registration Confirmation";
                        mailDetail.Template    = TemplateType.UserRegistration;
                        mailDetail.MessageBody = userViewModel;
                        GenericHelper.Send(mailDetail, _configuration, _hostingEnvironment);
                    }
                    result.Body = userModel.UserId;
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.Status  = Status.Error;
            }
            return(result);
        }
        public static void Send(MailDetailModel mailDetail, IConfiguration config, IHostingEnvironment hostingEnvironment)
        {
            var msgBody = "";

            if (mailDetail.Template == TemplateType.UserRegistration)
            {
                var file = config["UserRegistrationTemplatePath"];
                var path = Path.Combine(hostingEnvironment.ContentRootPath, file);
                using (StreamReader reader = new StreamReader(path))
                {
                    msgBody = reader.ReadToEnd();
                }
                var userViewModel = mailDetail.MessageBody;
                msgBody = msgBody.Replace("{FirstName}", userViewModel.FirstName);
                msgBody = msgBody.Replace("{Password}", userViewModel.Password);
                msgBody = msgBody.Replace("{UserName}", userViewModel.UserName);
            }
            else if (mailDetail.Template == TemplateType.ScheduleUserForInterview)
            {
                var file = config["ScheduleInterviewTemplatePath"];
                var path = Path.Combine(hostingEnvironment.ContentRootPath, file);
                using (StreamReader reader = new StreamReader(path))
                {
                    msgBody = reader.ReadToEnd();
                }
                var scheduledUser = mailDetail.MessageBody;
                msgBody = msgBody.Replace("{FirstName}", scheduledUser.User.FirstName);
                msgBody = msgBody.Replace("{ApprovalEvent}", scheduledUser.ApprovalEvent.ApprovalEventName);
                msgBody = msgBody.Replace("{Date}", scheduledUser.InterviewScheduledDate);
                msgBody = msgBody.Replace("{Time}", scheduledUser.InterviewScheduledTime);
                msgBody = msgBody.Replace("{Candidate}", scheduledUser.Candidate.FirstName + " " + scheduledUser.Candidate.LastName);
            }
            else if (mailDetail.Template == TemplateType.InterviewCancelled)
            {
                var file = config["InterviewCancelledTemplatePath"];
                var path = Path.Combine(hostingEnvironment.ContentRootPath, file);
                using (StreamReader reader = new StreamReader(path))
                {
                    msgBody = reader.ReadToEnd();
                }
                var scheduledUser = mailDetail.MessageBody;
                msgBody = msgBody.Replace("{FirstName}", scheduledUser.User.FirstName);
                msgBody = msgBody.Replace("{ApprovalEvent}", scheduledUser.ApprovalEvent.ApprovalEventName);
                msgBody = msgBody.Replace("{Date}", scheduledUser.InterviewScheduledDate);
                msgBody = msgBody.Replace("{Time}", scheduledUser.InterviewScheduledTime);
                msgBody = msgBody.Replace("{Candidate}", scheduledUser.Candidate.FirstName + " " + scheduledUser.Candidate.LastName);
            }
            else
            {
                msgBody = "";
            }
            SendMail(mailDetail.EmailId, mailDetail.Subject, msgBody, config);
        }