Exemple #1
0
        public async Task <ExecutionResponse <MetricModel> > CreateMetric(UpdateMetricModel model)
        {
            var oldMetric = _metricQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower() && x.CompanyId == CurrentCompanyId);

            if (oldMetric != null)
            {
                throw new Exception("Metric already exists");
            }

            //save metric info
            var metric = new Metric
            {
                Name         = model.Name,
                DepartmentId = model.DepartmentId,
                Description  = model.Description,
                CompanyId    = CurrentCompanyId,
                CreateById   = _httpContext.GetCurrentSSOUserId()
            };

            await _metricCommandRepo.InsertAsync(metric);

            await _metricCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <MetricModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <MetricModel>(metric)
            });
        }
Exemple #2
0
        public async Task <ExecutionResponse <VenueModel> > CreateVenue(VenueModel model)
        {
            var oldVenue = _venueQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower());

            if (oldVenue != null)
            {
                throw new Exception("Venue already exists");
            }

            //save venue info
            var venue = new Venue
            {
                Name        = model.Name,
                CompanyId   = CurrentCompanyId,
                Description = model.Description,
                CreateById  = _httpContext.GetCurrentSSOUserId()
            };

            await _venueCommandRepo.InsertAsync(venue);

            await _venueCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <VenueModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <VenueModel>(venue)
            });
        }
        public async Task <ExecutionResponse <InterviewSessionModel> > CreateInterviewSession(InterviewSessionModel model)
        {
            //save interviewSession info
            var interviewSession = new InterviewSession
            {
                StartTime   = model.StartTime,
                EndTime     = model.EndTime,
                Subject     = model.Subject,
                VenueId     = model.VenueId,
                RecruiterId = _httpContext.GetCurrentUserId(),
                CompanyId   = CurrentCompanyId,
                JobRoleId   = model.JobRoleId,
                CreateById  = _httpContext.GetCurrentSSOUserId()
            };

            await _interviewSessionCommandRepo.InsertAsync(interviewSession);

            await _interviewSessionCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <InterviewSessionModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <InterviewSessionModel>(interviewSession)
            });
        }
Exemple #4
0
        public async Task <ExecutionResponse <CompanyModel> > CreateCompany(CompanyModel model)
        {
            var oldCompany = _companyQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower());

            if (oldCompany != null)
            {
                throw new Exception("Company already exists");
            }

            //save company info
            var company = new Company
            {
                Name       = model.Name,
                Code       = model.Code,
                CreateById = _httpContext.GetCurrentSSOUserId()
            };

            await _companyCommandRepo.InsertAsync(company);

            await _companyCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <CompanyModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <CompanyModel>(company)
            });
        }
Exemple #5
0
        public async Task <ExecutionResponse <DepartmentModel> > CreateDepartment(DepartmentModel model)
        {
            var oldDepartment = _departmentQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower());

            if (oldDepartment != null)
            {
                throw new Exception("Department already exists");
            }

            //save department info
            var department = new Department
            {
                Name        = model.Name,
                CompanyId   = CurrentCompanyId,
                Description = model.Description,
                CreateById  = _httpContext.GetCurrentSSOUserId()
            };

            await _departmentCommandRepo.InsertAsync(department);

            await _departmentCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <DepartmentModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <DepartmentModel>(department)
            });
        }
Exemple #6
0
        public async Task <ActionResult> Create(PermissionViewModel permissionVm)
        {
            try
            {
                CreateViewBagParams();
                if (ModelState.IsValid)
                {
                    var permission = new Permission()
                    {
                        Name      = permissionVm.PermissionName,
                        Code      = permissionVm.PermissionCode,
                        CreatedBy = User.Identity.GetUserId <Int64>()
                    };
                    await _permissionCommand.InsertAsync(permission);

                    await _permissionCommand.SaveChangesAsync();

                    _activityRepo.CreateActivityLog(string.Format("Created Portal permission with Name:{0}", permission.Name), this.GetContollerName(), this.GetContollerName(), User.Identity.GetUserId <Int64>(), permission);

                    TempData["MESSAGE"] = "Permission " + permissionVm.PermissionName + " was successfully created";
                    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", permissionVm));
                }
            }
            catch (Exception exp)
            {
                _log.Error(exp);
                return(View("Error"));
            }
        }
Exemple #7
0
        public async Task <ActionResult> Create(PermissionViewModel permissionVm)
        {
            long currentUserId = GetCurrentUserId();

            try
            {
                CreateViewBagParams();
                if (ModelState.IsValid)
                {
                    var permission = _mapper.Map <PermissionViewModel, Permission>(permissionVm);
                    permission.CreatedBy = currentUserId;
                    await _permissionCommand.InsertAsync(permission);

                    await _permissionCommand.SaveChangesAsync();

                    _activityRepo.CreateActivityLog(string.Format("Created Portal permission with Name:{0}", permission.Name), this.ControllerContext.ActionDescriptor.ControllerName, this.ControllerContext.ActionDescriptor.ActionName, currentUserId, permission);

                    TempData["MESSAGE"] = "Permission " + permissionVm.PermissionName + " was successfully created";
                    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", permissionVm));
                }
            }
            catch (Exception exp)
            {
                _log.LogError(exp.Message);
                return(View("Error"));
            }
        }
Exemple #8
0
        public async Task <ExecutionResponse <JobRoleModel> > CreateJobRole(UpdateJobRoleModel model)
        {
            var oldJobRole = _jobRoleQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower() && x.Department.CompanyId == CurrentCompanyId);

            if (oldJobRole != null)
            {
                throw new Exception("Job Role already exists");
            }

            if (!_departmentQueryRepo.GetAll().Any(d => d.Id == model.DepartmentId && d.CompanyId == CurrentCompanyId))
            {
                return new ExecutionResponse <JobRoleModel>
                       {
                           ResponseCode = ResponseCode.NotFound,
                           Message      = "Department does not exist"
                       }
            }
            ;

            //save jobRole info
            var jobRole = new JobRole
            {
                Name         = model.Name,
                DepartmentId = model.DepartmentId,
                Description  = model.Description,
                CreateById   = _httpContext.GetCurrentSSOUserId()
            };

            await _jobRoleCommandRepo.InsertAsync(jobRole);

            await _jobRoleCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <JobRoleModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <JobRoleModel>(jobRole)
            });
        }
        public async Task <ExecutionResponse <object> > SetInterviewInterviewers(long[] interviewerIds, long interviewSessionId)
        {
            try
            {
                var interviewSession = _interviewSessionQueryRepo.GetAll().FirstOrDefault(x => x.Id == interviewSessionId && x.CompanyId == CurrentCompanyId);

                if (interviewSession == null)
                {
                    throw new Exception("Interview session does not exist");
                }

                var interviewInterviewers = _interviewSessionInterviewerQueryRepo.GetAll().Where(x => x.InterviewSessionId == interviewSessionId);

                //to add
                foreach (var id in interviewerIds)
                {
                    if (!interviewInterviewers.Select(x => x.Id).ToArray().Contains(id))
                    {
                        await _interviewSessionInterviewerCommandRepo.InsertAsync(new InterviewSessionInterviewer { InterviewSessionId = interviewSessionId, InterviewerId = id, CreateById = _httpContext.GetCurrentSSOUserId() });
                    }
                }

                //to remove
                foreach (var item in interviewInterviewers.ToList())
                {
                    if (!interviewerIds.Contains(item.Id))
                    {
                        await _interviewSessionInterviewerCommandRepo.DeleteAsync(item);
                    }
                }

                await _interviewSessionInterviewerCommandRepo.SaveChangesAsync();

                return(new ExecutionResponse <object>
                {
                    ResponseData = true,
                    ResponseCode = ResponseCode.Ok
                });
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(new ExecutionResponse <object>
                {
                    ResponseData = false,
                    ResponseCode = ResponseCode.ServerException,
                    Message = ex.Message
                });
            }
        }
Exemple #10
0
        public async Task <ActionResult> Edit(int id, EmailViewModel systememail)
        {
            try
            {
                if (id <= 0)
                {
                    return(new BadRequestResult());
                }

                if (ModelState.IsValid)
                {
                    EmailTemplate emailTemplate = await _EmailTemplateQuery.GetAsync(id);

                    if (emailTemplate == null)
                    {
                        return(NotFound($"Unable to load permission with ID '{id}'."));
                    }
                    emailTemplate.Body = systememail.EmailText;
                    await _EmailTemplateCommand.UpdateAsync(emailTemplate);

                    await _EmailTemplateCommand.SaveChangesAsync();

                    TempData["MESSAGE"] = "Email Template " + emailTemplate.Name + " was successfully updated";
                    ModelState.Clear();
                    return(Json(new { success = true }));
                }
                else
                {
                    foreach (var modelError in ModelState.Values.SelectMany(modelState => modelState.Errors))
                    {
                        ModelState.AddModelError(string.Empty, modelError.ErrorMessage);
                    }
                    return(PartialView("_PartialAddEdit", systememail));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                _log.LogInformation(ex.Message);
                return(View("Error"));
            }
        }
Exemple #11
0
        public async Task CreateActivityLogAsync(string descriptn, string moduleName, string moduleAction, Int64 userid, object record)
        {
            try
            {
                ActivityLog alog = new ActivityLog
                {
                    ModuleName   = moduleName,
                    ModuleAction = moduleAction,
                    UserId       = userid,
                    Description  = descriptn,
                    Record       = record != null?JsonConvert.SerializeObject(record) : "N/A"
                };
                await _activityLogRepositoryCommand.InsertAsync(alog);

                await _activityLogRepositoryCommand.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _log.Error(ex);
            }
        }
Exemple #12
0
        public async Task <ActionResult> Edit(UserViewModel model)
        {
            string code = string.Empty;

            model.Roles = _utility.GetRoles();
            try
            {
                EditViewBagParams();
                if (ModelState.IsValid)
                {
                    //checking if emailaddress does not exist b4
                    var organizerAdminEmailExist = _applicationUserQuery.GetAllList(m => m.Email.ToLower().Trim() == model.Email.ToLower().Trim() && m.Id != model.Id).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() && m.Id != model.Id).ToList();
                    if (organizerAdminUsernameExist.Any())
                    {
                        ModelState.AddModelError("", "username already exist");
                        return(PartialView("_PartialAddEdit", model));
                    }

                    ApplicationUser usermodel = await _applicationUserQuery.GetAsync(model.Id);

                    if (usermodel != null)
                    {
                        usermodel.FirstName    = model.FirstName;
                        usermodel.LastName     = model.LastName;
                        usermodel.MiddleName   = model.MiddleName;
                        usermodel.MobileNumber = model.MobileNumber;
                        usermodel.PhoneNumber  = model.PhoneNumber;
                        usermodel.DOB          = model.DOB.HasValue ? model.DOB : null;
                        usermodel.Address      = model.Address;
                        await _applicationUserCommand.UpdateAsync(usermodel);

                        await _applicationUserCommand.SaveChangesAsync();

                        _activityRepo.CreateActivityLog(string.Format("Updtae User Id:{0} with Name :{1}", usermodel.Id, (usermodel.LastName + " " + usermodel.FirstName)), this.GetContollerName(), this.GetActionName(), usermodel.Id, null);


                        //update UserRole
                        //.First delete role if exist
                        //Add the new role
                        _applicationUserQuery.ExecuteStoreprocedure(AppConstant.DeleteUserRoleByUserId + " @UserId", new SqlParameter("UserId", usermodel.Id));
                        await UserManager.AddToRolesAsync(usermodel.Id, model.SelectedRole.ToArray <string>());

                        _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.GetActionName(), usermodel.Id, null);

                        TempData["MESSAGE"] = "Portal User " + (usermodel.LastName + " " + usermodel.FirstName) + " was successfully created";
                        ModelState.Clear();
                        return(Json(new { success = true }));
                    }
                    else
                    {
                        ModelState.AddModelError("", "An error occurred while processing your request");
                    }
                    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);
                model.Roles = _utility.GetRoles();
                //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));
            }
        }
Exemple #13
0
        public async Task <ExecutionResponse <UserModel> > AddUserRole(UserRoleModel model)
        {
            var role = _roleQueryRepo.GetAll().FirstOrDefault(f => f.Id == model.RoleId);

            if (role == null)
            {
                return(new ExecutionResponse <UserModel>
                {
                    ResponseCode = ResponseCode.NotFound,
                    Message = "Role does not exist"
                });
            }

            if (CurrentCompanyId == 0 && role.RoleName != "CompanyAdmin")
            {
                throw new Exception($"You cannot add role '{role.RoleName}' to a user");
            }

            var user = _userQueryRepo.GetAll().FirstOrDefault(f => f.Id == model.UserId);

            if (user == null || (CurrentCompanyId != 0 && user.CompanyId != CurrentCompanyId))
            {
                return(new ExecutionResponse <UserModel>
                {
                    ResponseCode = ResponseCode.NotFound,
                    Message = "User does not exist"
                });
            }

            if (!user.UserRoles.Any(u => u.RoleId == role.Id))
            {
                var result = await _ssoService.AddRemoveClaims(new UserClaimModel { Claims = new List <SSOClaim> {
                                                                                        new SSOClaim("role", role.RoleName)
                                                                                    }, UserId = user.SSOUserId }, ClaimAction.Add);

                if (result.ResponseCode == ResponseCode.Ok)
                {
                    await _userRoleCommandRepo.InsertAsync(new UserRole { RoleId = role.Id, UserId = user.Id });

                    await _userRoleCommandRepo.SaveChangesAsync();

                    return(await GetUser(model.UserId));
                }
                else
                {
                    return(new ExecutionResponse <UserModel>
                    {
                        ResponseCode = ResponseCode.ServerException,
                        Message = result.Message
                    });
                }
            }
            else
            {
                return(new ExecutionResponse <UserModel>
                {
                    ResponseCode = ResponseCode.ServerException,
                    Message = "User is already attached to specified role"
                });
            }
        }
Exemple #14
0
        public async Task <ExecutionResponse <UserModel> > CreateUser(CreateUserModel model)
        {
            if (_userQueryRepo.GetAll().Any(u => u.Email.Trim().ToLower() == model.Email.Trim().ToLower()))
            {
                return new ExecutionResponse <UserModel>
                       {
                           ResponseCode = ResponseCode.ServerException,
                           Message      = "User with specified email already exists"
                       }
            }
            ;

            var role = _roleQueryRepo.GetAll().FirstOrDefault(x => x.Id == model.RoleId);

            if (role == null)
            {
                throw new Exception("Invalid Role");
            }

            if (CurrentCompanyId == 0 && role.RoleName != "CompanyAdmin")
            {
                throw new Exception($"You cannot create a user with role '{role.RoleName}'");
            }

            var company = _companyQueryRepo.GetAll().FirstOrDefault(x => x.Id == model.CompanyId);

            if (company == null)
            {
                throw new Exception("Company does not exist");
            }

            var registerReponse = await _ssoService.Register(new SSOUserDto
            {
                Claims = new List <SSOClaim> {
                    new SSOClaim("role", GetSSORole(role.RoleName)),
                    new SSOClaim("role", role.RoleName)
                },
                ConfirmEmail = false,
                Email        = model.Email,
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                PhoneNumber  = string.IsNullOrEmpty(model.PhoneNumber) ? "08111111111" : model.PhoneNumber,
                UserName     = model.UserName,
                Password     = model.Password
            });

            if (registerReponse.ResponseCode != ResponseCode.Ok)
            {
                return new ExecutionResponse <UserModel>
                       {
                           ResponseCode = ResponseCode.ServerException,
                           Message      = registerReponse.Message
                       }
            }
            ;

            //user registered on sso
            //trigger reset password

            //save user info
            var user = new User
            {
                Email          = model.Email,
                FirstName      = model.FirstName,
                LastName       = model.LastName,
                PhoneNumber    = string.IsNullOrEmpty(model.PhoneNumber) ? "08111111111" : model.PhoneNumber,
                UserName       = model.UserName,
                CompanyId      = CurrentCompanyId == 0 ? model.CompanyId : CurrentCompanyId,
                EmailConfirmed = false,
                CreateById     = CurrentUserId,
                SSOUserId      = registerReponse.ResponseData.UserId
            };
            await _userCommandRepo.InsertAsync(user);

            await _userCommandRepo.SaveChangesAsync();

            //assign role to user
            await _userRoleCommandRepo.InsertAsync(new UserRole { RoleId = role.Id, UserId = user.Id, CreateById = CurrentUserId });

            await _userRoleCommandRepo.SaveChangesAsync();

            //send email confirmation mail
            _emailService.EmailConfirmation(registerReponse.ResponseData.EmailConfirmationToken, model.Email, $"{model.FirstName} {model.LastName}", registerReponse.ResponseData.UserId);


            return(new ExecutionResponse <UserModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <UserModel>(user)
            });
        }
        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"));
            }
        }
        public async Task <ActionResult> Edit(ArtistViewModel model, HttpPostedFileBase profileImage)
        {
            string code        = string.Empty;
            string profilePath = string.Empty;

            try
            {
                EditViewBagParams();
                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));
                        }
                    }

                    ApplicationUser usermodel = await _applicationUserQuery.GetAsync(model.Id);

                    if (usermodel != null)
                    {
                        usermodel.FirstName    = model.FirstName;
                        usermodel.LastName     = model.LastName;
                        usermodel.MiddleName   = model.MiddleName;
                        usermodel.MobileNumber = model.MobileNumber;
                        usermodel.PhoneNumber  = model.PhoneNumber;
                        usermodel.DOB          = !string.IsNullOrEmpty(model.DOB) ? ExtentionUtility.ConvertDateValue(model.DOB) : DateTime.MinValue;
                        usermodel.Address      = model.Address;
                        usermodel.PicturePath  = Path.GetFileName(profilePath);
                        usermodel.FacebookURL  = model.FacebookURL;
                        await _applicationUserCommand.UpdateAsync(usermodel);

                        await _applicationUserCommand.SaveChangesAsync();

                        _activityRepo.CreateActivityLog(string.Format("Updtae User Id:{0} with Name :{1}", usermodel.Id, (usermodel.LastName + " " + usermodel.FirstName)), this.GetContollerName(), this.GetActionName(), usermodel.Id, null);

                        _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.GetActionName(), usermodel.Id, null);

                        TempData["MESSAGE"] = "Artist " + (usermodel.LastName + " " + usermodel.FirstName) + " was successfully created";
                        ModelState.Clear();
                        return(Json(new { success = true }));
                    }
                    else
                    {
                        ModelState.AddModelError("", "An error occurred while processing your request");
                    }
                    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));
            }
        }