public IEnumerable <SelectListItem> GetEmailTemplateToken(string code)
        {
            var types = _EmailTokenQuery.GetAllList(c => c.EmailCode == code).Select(x =>
                                                                                     new SelectListItem
            {
                Value = x.Token.ToString(),
                Text  = x.Token
            });

            return(new SelectList(types, "Value", "Text"));
        }
Beispiel #2
0
 public void SendPasswordResetEmail(ApplicationUser mUser, string resetUrl)
 {
     try
     {
         EmailTemplate     emailFormat = _emailTemplateRepositoryQuery.GetAllList(m => m.Code == "F_PASSWORD").SingleOrDefault();
         List <EmailToken> tokenCol    = _emailTokenRepositoryQuery.GetAllList(m => m.EmailCode == emailFormat.Code).ToList();
         foreach (var token in tokenCol)
         {
             if (token.Token.Equals("{Name}"))
             {
                 token.PreviewText = mUser.FirstName + " " + mUser.LastName;
             }
             else if (token.Token.Equals("{Email}"))
             {
                 token.PreviewText = mUser.Email ?? string.Empty;
             }
             else if (token.Token.Equals("{Url}"))
             {
                 token.PreviewText = resetUrl;
             }
         }
         try
         {
             EmailLog mlog = new EmailLog();
             mlog.Receiver         = mUser.Email;
             mlog.Sender           = ExtentionUtility.GetAppSetting("MailFrom");
             mlog.Subject          = "Password Reset Notification";
             mlog.MessageBody      = ExtentionUtility.GeneratePreviewHTML(emailFormat.Body, tokenCol);
             mlog.DateCreated      = mlog.DateToSend = DateTime.Now;
             mlog.IsSent           = mlog.HasAttachment = false;
             mlog.EmailAttachments = new List <EmailAttachment>();
             _emailLogRepositoryCommand.Insert(mlog);
             _emailLogRepositoryCommand.SaveChanges();
         }
         catch (DbEntityValidationException filterContext)
         {
             if (typeof(DbEntityValidationException) == filterContext.GetType())
             {
                 foreach (var validationErrors in filterContext.EntityValidationErrors)
                 {
                     foreach (var validationError in validationErrors.ValidationErrors)
                     {
                         System.Diagnostics.Debug.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                     }
                 }
             }
             throw;
         }
     }
     catch
     {
         throw;
     }
 }
        // GET: ApplicationRoles/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            try
            {
                EditViewBagParams();
                if (id <= 0)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                ApplicationRole applicationRole = await RoleManager.FindByIdAsync(id);

                if (applicationRole == null)
                {
                    return(HttpNotFound());
                }
                ApplicationRoleViewModel applicationRoleViewModel = new ApplicationRoleViewModel
                {
                    Id                   = applicationRole.Id,
                    Name                 = applicationRole.Name,
                    Permissions          = _utility.GetPermissions(),
                    SelectedPermissionId = _rolePermissionyQuery.GetAllList(c => c.RoleId == id).Select(c => c.PermissionId).ToList(),
                };
                return(PartialView("_PartialAddEdit", applicationRoleViewModel));
            }
            catch (Exception exp)
            {
                _log.Error(exp);
                return(View("Error"));
            }
        }
Beispiel #4
0
        public MailMessage GenerateMail(EmailLog emaillog)
        {
            try
            {
                var emailfrom = System.Configuration.ConfigurationManager.AppSettings["MailFrom"];
                var logourl   = System.Configuration.ConfigurationManager.AppSettings["LogoUrl"];

                String mailTo = emaillog.Receiver;
                // MailMessage mailMessage = new MailMessage();
                // mailMessage.From=(new MailAddress(emailfrom, "*****@*****.**"));
                MailMessage mailMessage = new MailMessage(new MailAddress(emailfrom, "*****@*****.**"), new MailAddress(mailTo, emaillog.Receiver));
                //string[] receivers = emaillog.Receiver.Split(';');
                //foreach (string s in receivers)
                //{
                //    mailMessage.To.Add(new MailAddress(s));
                //}
                //string[] cc = emaillog.CC.Split(';');
                //foreach (string s in cc)
                //{
                //    if (s.Trim() != "")
                //    {
                //        mailMessage.CC.Add(new MailAddress(s));
                //    }
                //}
                //string[] bcc = emaillog.BCC.Split(';');
                //foreach (string s in bcc)
                //{
                //    if (s.Trim() != "")
                //    {
                //        mailMessage.Bcc.Add(new MailAddress(s));
                //    }
                //}

                if (emaillog.HasAttachment)
                {
                    List <EmailAttachment> attachments = _emailAttachmentQuery.GetAllList(m => m.EmailLogID == emaillog.Id).ToList();
                    if (attachments.Any())
                    {
                        foreach (EmailAttachment attach in attachments)
                        {
                            if (File.Exists(attach.FilePath))
                            {
                                mailMessage.Attachments.Add(new Attachment(attach.FilePath));
                            }
                        }
                    }
                }
                mailMessage.Subject    = emaillog.Subject;
                mailMessage.IsBodyHtml = true;
                mailMessage.Body       = emaillog.MessageBody;
                return(mailMessage);
            }
            catch (Exception e)
            {
                _log.Info(e);
                throw e;
            }
        }
Beispiel #5
0
 public ActionResult Index()
 {
     try
     {
         _log.LogInformation("<<< In Portal Role Page >>>");
         if (TempData["MESSAGE"] != null)
         {
             ViewBag.Msg = TempData["MESSAGE"] as string;
         }
         var result = _mapper.Map <List <ApplicationRoleViewModel> >(_rolePermissionyQuery.GetAllList());
         return(View(result));
     }
     catch (Exception ex)
     {
         _log.LogError(ex.Message);
         return(View("Error"));
     }
 }
Beispiel #6
0
        public IEnumerable <SelectListItem> GetRoles()
        {
            var types = _applicationRoleQuery.GetAllList().Select(x =>
                                                                  new SelectListItem
            {
                Value = x.Name,
                Text  = x.Name
            }).AsEnumerable();

            return(new SelectList(types, "Value", "Text"));
        }
Beispiel #7
0
        public IEnumerable <SelectListItem> GetPermissions()
        {
            var types = _permissionQuery.GetAllList().Select(x =>
                                                             new SelectListItem
            {
                Value = x.Id.ToString(),
                Text  = x.Name
            }).AsEnumerable();

            return(new SelectList(types, "Value", "Text"));
        }
Beispiel #8
0
        //



        public IEnumerable <SelectListItem> GetApplicationUsers()
        {
            var types = _applicationUserQuery.GetAllList().Select(x =>
                                                                  new SelectListItem
            {
                Value = x.Id.ToString(),
                Text  = x.LastName + ' ' + x.FirstName
            }).AsEnumerable();

            return(new SelectList(types, "Value", "Text"));
        }
Beispiel #9
0
        public Task SendEmailResetPasswordAsync(string emailcode, ApplicationUser usermodel, string resetUrl)
        {
            if (string.IsNullOrEmpty(emailcode))
            {
                List <EmailToken> emailtoken = new List <EmailToken>();
                var emailTemplate            = _emailTemplateQuery.FirstOrDefault(m => m.Code == emailcode);
                if (emailTemplate.Id > 0)
                {
                    List <EmailToken> tokenCol = _emailTokenQuery.GetAllList(m => m.EmailCode == emailTemplate.Code).ToList();
                    foreach (var token in tokenCol)
                    {
                        if (token.Token.Equals("{Name}"))
                        {
                            token.PreviewText = usermodel.FirstName + " " + usermodel.LastName;
                        }
                        else if (token.Token.Equals("{Email}"))
                        {
                            token.PreviewText = usermodel.Email ?? string.Empty;
                        }
                        else if (token.Token.Equals("{Url}"))
                        {
                            token.PreviewText = resetUrl;
                        }
                    }

                    EmailLog mlog = new EmailLog();
                    mlog.Receiver    = usermodel.Email;
                    mlog.Sender      = _appSettings.EmailFromAddress;
                    mlog.Subject     = "Password Reset Notification";
                    mlog.MessageBody = GeneratePreviewHTML(emailTemplate.Body, tokenCol);
                    mlog.DateCreated = mlog.DateToSend = DateTime.Now;
                    mlog.IsSent      = mlog.HasAttachment = false;
                    var messageresponse = EmailSenderHelper(mlog.Receiver, mlog.Subject, mlog.MessageBody);
                    if (messageresponse.success)
                    {
                        mlog.IsSent = true;
                    }
                    _emailLogRepositoryCommand.Insert(mlog);
                    _emailLogRepositoryCommand.SaveChanges();
                }
            }
            return(Task.CompletedTask);
        }
Beispiel #10
0
 public void Execute()
 {
     try
     {
         List <EmailLog> emaillogmodellist = _emailJobQuery.GetAllList(m => m.IsSent == false && m.DateToSend <= DateTime.Now).Take(10).ToList();
         if (emaillogmodellist.Any())
         {
             foreach (EmailLog emaillogmodel in emaillogmodellist)
             {
                 try
                 {
                     MailMessage msg    = GenerateMail(emaillogmodel);
                     bool        result = Utilities.EmailHandler.Send(msg);
                     if (result)
                     {
                         emaillogmodel.DateSent = DateTime.Now;
                         emaillogmodel.IsSent   = true;
                     }
                     else
                     {
                         emaillogmodel.IsSent = false;
                         emaillogmodel.Retires++;
                     }
                     _emailJobCommand.Update(emaillogmodel);
                     _emailJobCommand.SaveChanges();
                 }
                 catch (Exception)
                 {
                     throw;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _log.Info(ex);
         throw;
     }
 }
Beispiel #11
0
        public async Task <ActionResult> Create(UserViewModel model)
        {
            string code = string.Empty;

            model.Roles = _utility.GetRoles();
            try
            {
                CreateViewBagParams();
                if (ModelState.IsValid)
                {
                    //checking if emailaddress does not exist b4
                    var organizerAdminEmailExist = _applicationUserQuery.GetAllList(m => m.Email.ToLower().Trim() == model.Email.ToLower().Trim()).ToList();
                    if (organizerAdminEmailExist.Any())
                    {
                        ModelState.AddModelError("", "email address already exist");
                        return(PartialView("_PartialAddEdit", model));
                    }

                    //checking if username does not exist b4
                    var organizerAdminUsernameExist = _applicationUserQuery.GetAllList(m => m.UserName.ToLower().Trim() == model.UserName.ToLower().Trim()).ToList();
                    if (organizerAdminUsernameExist.Any())
                    {
                        ModelState.AddModelError("", "username already exist");
                        return(PartialView("_PartialAddEdit", model));
                    }

                    ApplicationUser usermodel = UserViewModel.ModeltoEntity(model);

                    var result = await UserManager.CreateAsync(usermodel, "Password");

                    if (result.Succeeded)
                    {
                        _activityRepo.CreateActivityLog(string.Format("Assinging User Id:{0} with Name :{1} to role Id's:{2}", usermodel.Id, (usermodel.LastName + " " + usermodel.FirstName), model.SelectedRole), this.GetContollerName(), this.GetContollerName(), usermodel.Id, null);

                        ApplicationUserPasswordHistory passwordModel = new ApplicationUserPasswordHistory();
                        passwordModel.UserId       = usermodel.Id;
                        passwordModel.DateCreated  = DateTime.Now;
                        passwordModel.HashPassword = ExtentionUtility.Encrypt("Password");
                        passwordModel.CreatedBy    = usermodel.Id;
                        _applicationUserPwdhistoryCommand.Insert(passwordModel);
                        _applicationUserPwdhistoryCommand.Save();

                        var addRoleResult = await UserManager.AddToRolesAsync(usermodel.Id, model.SelectedRole.ToArray <string>());

                        if (addRoleResult.Succeeded)
                        {
                            //send user reset mail
                            code = await UserManager.GeneratePasswordResetTokenAsync(usermodel.Id);

                            string portalUrl = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";

                            var    callbackUrl = Url.Action("ResetPassword", "Account", new { userId = usermodel.Id, code = code });
                            string mPre        = portalUrl + callbackUrl;
                            _log.Info(string.Format("Reset URL:{0}", mPre));
                            if (!String.IsNullOrEmpty(usermodel.Email))
                            {
                                try
                                {
                                    _utility.SendWelcomeAndPasswordResetEmail(usermodel, mPre);
                                }
                                catch  { }
                            }


                            TempData["MESSAGE"] = "Portal User " + (usermodel.LastName + " " + usermodel.FirstName) + " was successfully created";
                            ModelState.Clear();
                            return(Json(new { success = true }));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", result.Errors.FirstOrDefault().ToString());
                    }
                    ModelState.Clear();
                    return(Json(new { success = true }));
                }
                else
                {
                    StringBuilder errorMsg = new StringBuilder();

                    foreach (var modelError in ModelState.Values.SelectMany(modelState => modelState.Errors))
                    {
                        errorMsg.AppendLine(modelError.ErrorMessage);
                        ModelState.AddModelError(string.Empty, modelError.ErrorMessage);
                    }
                    ViewBag.ErrMsg = errorMsg.ToString();
                    return(PartialView("_PartialAddEdit", model));
                }
            }
            catch (Exception exp)
            {
                _log.Error(exp);
                //return View("Error");
                StringBuilder errorMsg = new StringBuilder();

                foreach (var modelError in ModelState.Values.SelectMany(modelState => modelState.Errors))
                {
                    errorMsg.AppendLine(modelError.ErrorMessage);
                    ModelState.AddModelError(string.Empty, modelError.ErrorMessage);
                }
                ViewBag.ErrMsg = errorMsg.ToString();
                return(PartialView("_PartialAddEdit", model));
            }
        }
Beispiel #12
0
        public async Task <ActionResult> FramewokAdmin(FrameworkSetupViewModel model, string nextButton, string backButton)
        {
            string msg;

            if (backButton != null)
            {
                return(RedirectToAction("FrameworkSetting"));
            }

            if (nextButton != null)
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                if (string.Compare(model.AdminUserSetting.Password,
                                   model.AdminUserSetting.ConfirmPassword, StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    ViewBag.ErrMsg = "Password and confirm password must be equal";
                    // ModelState.AddModelError("","Password and confirm password must be equal");
                    return(View(model));
                }

                var roleIndb = _applicationRoleQuery.GetAllList();
                if (_userManager.Users.ToList().Any())
                {
                    var adminusermodel = _userManager.Users.ToList().FirstOrDefault();
                    var tokencode      = await _userManager.GeneratePasswordResetTokenAsync(adminusermodel);

                    var result = await _userManager.ResetPasswordAsync(adminusermodel, tokencode, model.AdminUserSetting.Password);

                    if (result.Succeeded)
                    {
                        ApplicationUserPasswordHistory passwordModel = new ApplicationUserPasswordHistory();
                        passwordModel.UserId       = adminusermodel.Id;
                        passwordModel.DateCreated  = DateTime.Now;
                        passwordModel.HashPassword = "";
                        //ExtensionUtility.Encrypt(model.AdminUserSetting.Password);
                        passwordModel.CreatedBy = adminusermodel.Id;
                        _applicationUserPwdhistoryCommand.Insert(passwordModel);
                        _applicationUserPwdhistoryCommand.Save();

                        var addRoleResult = await _userManager.AddToRoleAsync(adminusermodel, "PortalAdmin");

                        if (addRoleResult.Succeeded)
                        {
                            Application applicationmodel = _applicationQuery.GetAll().FirstOrDefault();
                            applicationmodel.HasAdminUserConfigured = true;
                            _applicationCommand.Update(applicationmodel);
                            _applicationCommand.SaveChanges();
                            return(RedirectToAction("Login", "Account"));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", result.Errors.FirstOrDefault().ToString());
                    }
                }
                else
                {
                    var usermodel = new ApplicationUser
                    {
                        FirstName            = model.AdminUserSetting.FirstName,
                        LastName             = model.AdminUserSetting.LastName,
                        MiddleName           = model.AdminUserSetting.MiddleName,
                        UserName             = model.AdminUserSetting.UserName,
                        Email                = model.AdminUserSetting.Email,
                        MobileNumber         = model.AdminUserSetting.MobileNumber,
                        PhoneNumber          = model.AdminUserSetting.PhoneNumber,
                        EmailConfirmed       = true,
                        PhoneNumberConfirmed = true,
                        TwoFactorEnabled     = false,
                        LockoutEnabled       = false,
                        AccessFailedCount    = 0,
                        DateCreated          = DateTime.Now,
                        IsFirstLogin         = false
                    };
                    var result = await _userManager.CreateAsync(usermodel, model.AdminUserSetting.Password);

                    if (result.Succeeded)
                    {
                        ApplicationUserPasswordHistory passwordModel = new ApplicationUserPasswordHistory();
                        passwordModel.UserId       = usermodel.Id;
                        passwordModel.DateCreated  = DateTime.Now;
                        passwordModel.HashPassword = "";
                        //ExtensionUtility.Encrypt(model.AdminUserSetting.Password);
                        passwordModel.CreatedBy = usermodel.Id;
                        _applicationUserPwdhistoryCommand.Insert(passwordModel);
                        _applicationUserPwdhistoryCommand.Save();

                        var addRoleResult = await _userManager.AddToRoleAsync(usermodel, "PortalAdmin");

                        if (addRoleResult.Succeeded)
                        {
                            Application applicationmodel = _applicationQuery.GetAll().FirstOrDefault();
                            applicationmodel.HasAdminUserConfigured = true;
                            _applicationCommand.Update(applicationmodel);
                            _applicationCommand.SaveChanges();
                            return(RedirectToAction("Login", "Account"));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", result.Errors.FirstOrDefault().ToString());
                    }
                }

                return(View(_setupContract));
            }

            var user     = _userManager.Users.ToList().FirstOrDefault();
            var userInfo = _mapper.Map <AdminUserSettingViewModel>(user);

            if (userInfo == null)
            {
                //ModelState.AddModelError("", "Unable to initialize admin user information due to internal error! Please try again later");
                return(View(_setupContract));
            }
            _setupContract.AdminUserSetting = userInfo;
            return(View(_setupContract));
        }
Beispiel #13
0
        public async Task <ActionResult> Create(EventViewModel eventVm)
        {
            string filename = string.Empty;
            string fileName = string.Empty;

            eventVm.Artists = _utility.GetAllArtists();
            try
            {
                CreateViewBagParams();
                if (ModelState.IsValid)
                {
                    //checking if organizer name does not exist b4
                    var eventnameExist = _EventQuery.GetAllList(m => m.EventName.ToLower().Trim() == eventVm.EventName.ToLower().Trim()).ToList();
                    if (eventnameExist.Any())
                    {
                        ModelState.AddModelError("", "Event name already exist");
                        return(PartialView("_PartialAddEdit", eventVm));
                    }

                    var eventmodel = new Event()
                    {
                        EventName        = eventVm.EventName,
                        EventDescription = eventVm.EventDescription,
                        Venue            = eventVm.Venue,
                        ArtistId         = eventVm.ArtistId,
                        City             = eventVm.City,
                        Country          = eventVm.Country,
                        StartDate        = ExtentionUtility.ConvertDateValue(eventVm.StartDate),
                        EndDate          = ExtentionUtility.ConvertDateValue(eventVm.EndDate),
                        CreatedBy        = GetCurrentUserID()
                    };
                    //Save Event
                    await _EventCommand.InsertAsync(eventmodel);

                    await _EventCommand.SaveChangesAsync();

                    _activityRepo.CreateActivityLog(string.Format("User ID: {0} Created event with event Name:{0}", GetCurrentUserID(), eventmodel.EventName), this.GetContollerName(), this.GetActionName(), GetCurrentUserID(), eventmodel);

                    TempData["MESSAGE"] = "Event " + eventmodel.EventName + " was successfully created";
                    ModelState.Clear();
                    return(Json(new { success = true }));
                }
                else
                {
                    StringBuilder errorMsg = new StringBuilder();

                    var errorModel =
                        from x in ModelState.Keys
                        where ModelState[x].Errors.Count > 0
                        select new
                    {
                        key    = x,
                        errors = ModelState[x].Errors.
                                 Select(y => y.ErrorMessage).
                                 ToArray()
                    };

                    foreach (var item in errorModel)
                    {
                        errorMsg.AppendLine(string.Format("Error Key: {0} Error Message: {1}", item.key, string.Join(",", item.errors)));
                        ModelState.AddModelError(item.key, string.Join(",", item.errors));
                    }
                    ViewBag.ErrMsg = errorMsg.ToString();
                    return(PartialView("_PartialAddEdit", eventVm));
                }
            }
            catch (Exception exp)
            {
                _log.Error(exp);
                return(View("Error"));
            }
        }
Beispiel #14
0
        public async Task <ActionResult> Create(ArtistViewModel model, HttpPostedFileBase profileImage)
        {
            string code        = string.Empty;
            string profilePath = string.Empty;

            try
            {
                CreateViewBagParams();
                if (ModelState.IsValid)
                {
                    if (profileImage != null && profileImage.ContentLength > 0)
                    {
                        var      ext = Path.GetExtension(profileImage.FileName).Trim().ToLower();
                        string[] allowedExtension = new string[] { ".jpeg", ".jpg", ".png" };
                        if (allowedExtension.Contains(ext))
                        {
                            profilePath = _utility.Upload(profileImage, _utility.GetAppSetting("AppUploadFolder"));
                        }
                        else
                        {
                            ModelState.AddModelError("", string.Format("Invalid image extension,allowed extension are: .jpeg,.jpg,.png ", allowedExtension));
                            //return PartialView("_PartialAddEdit", staffVm);
                            return(View("_PartialAddEdit", model));
                        }
                    }


                    //checking if emailaddress does not exist b4
                    var organizerAdminEmailExist = _applicationUserQuery.GetAllList(m => m.Email.ToLower().Trim() == model.Email.ToLower().Trim()).ToList();
                    if (organizerAdminEmailExist.Any())
                    {
                        ModelState.AddModelError("", "email address already exist");
                        return(PartialView("_PartialAddEdit", model));
                    }

                    //checking if username does not exist b4
                    var organizerAdminUsernameExist = _applicationUserQuery.GetAllList(m => m.UserName.ToLower().Trim() == model.UserName.ToLower().Trim()).ToList();
                    if (organizerAdminUsernameExist.Any())
                    {
                        ModelState.AddModelError("", "username already exist");
                        return(PartialView("_PartialAddEdit", model));
                    }

                    ApplicationUser usermodel = ArtistViewModel.ModeltoEntity(model);
                    usermodel.PicturePath = Path.GetFileName(profilePath);
                    usermodel.FacebookURL = model.FacebookURL;

                    var result = await UserManager.CreateAsync(usermodel, "Password");

                    if (result.Succeeded)
                    {
                        _activityRepo.CreateActivityLog(string.Format("Assinging User Id:{0} with Name :{1} to role Id's:{2}", usermodel.Id, (usermodel.LastName + " " + usermodel.FirstName), ""), this.GetContollerName(), this.GetContollerName(), usermodel.Id, null);

                        ApplicationUserPasswordHistory passwordModel = new ApplicationUserPasswordHistory();
                        passwordModel.UserId       = usermodel.Id;
                        passwordModel.DateCreated  = DateTime.Now;
                        passwordModel.HashPassword = ExtentionUtility.Encrypt("Password");
                        passwordModel.CreatedBy    = usermodel.Id;
                        _applicationUserPwdhistoryCommand.Insert(passwordModel);
                        _applicationUserPwdhistoryCommand.Save();

                        var addRoleResult = await UserManager.AddToRoleAsync(usermodel.Id, "Artist");

                        if (addRoleResult.Succeeded)
                        {
                            //send user reset mail
                            code = await UserManager.GeneratePasswordResetTokenAsync(usermodel.Id);

                            string portalUrl = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";

                            var    callbackUrl = Url.Action("ResetPassword", "Account", new { userCode = usermodel.Id.EncryptID(), code = code });
                            string mPre        = portalUrl + callbackUrl;
                            _log.Info(string.Format("Reset URL:{0}", mPre));
                            if (!String.IsNullOrEmpty(usermodel.Email))
                            {
                                _utility.SendWelcomeAndPasswordResetEmail(usermodel, mPre);
                            }


                            TempData["MESSAGE"] = "Artist " + (usermodel.LastName + " " + usermodel.FirstName) + " was successfully created";
                            ModelState.Clear();
                            return(Json(new { success = true }));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", result.Errors.FirstOrDefault().ToString());
                    }
                    ModelState.Clear();
                    return(Json(new { success = true }));
                }
                else
                {
                    StringBuilder errorMsg = new StringBuilder();

                    foreach (var modelError in ModelState.Values.SelectMany(modelState => modelState.Errors))
                    {
                        errorMsg.AppendLine(modelError.ErrorMessage);
                        ModelState.AddModelError(string.Empty, modelError.ErrorMessage);
                    }
                    ViewBag.ErrMsg = errorMsg.ToString();
                    return(PartialView("_PartialAddEdit", model));
                }
            }
            catch (Exception exp)
            {
                _log.Error(exp);
                //return View("Error");
                StringBuilder errorMsg = new StringBuilder();

                foreach (var modelError in ModelState.Values.SelectMany(modelState => modelState.Errors))
                {
                    errorMsg.AppendLine(modelError.ErrorMessage);
                    ModelState.AddModelError(string.Empty, modelError.ErrorMessage);
                }
                ViewBag.ErrMsg = errorMsg.ToString();
                return(PartialView("_PartialAddEdit", model));
            }
        }