public ActionResult EditorAjax(int id, string workerId) { WorkerInRole workerinrole = null; if (id > 0) { //find an existing workerinrole from database workerinrole = workerinroleRepository.Find(id); if (workerinrole == null) { //throw an exception if id is provided but data does not exist in database return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound, "Worker In Role not found")); } } else { //create a new instance if id is not provided workerinrole = new WorkerInRole(); workerinrole.WorkerID = workerId.ToInteger(true); } if (IsRegionalAdministrator) { workerinrole.AllSubPrograms = subprogramRepository.FindAllByWordkerID(CurrentLoggedInWorker.ID, 0).ToList(); } else { workerinrole.AllSubPrograms = subprogramRepository.All.Where(item => item.IsActive == true).ToList(); } workerinrole.AssignedSubPrograms = workersubprogramRepository.All.Where(item => item.WorkerInRoleID == id).ToList(); //ViewBag.Programs = programRepository.All.AsEnumerable().Select(o => new { ID = o.ID, Name = o.Name }).ToList(); //return the html of editor to display on popup return(Content(this.RenderPartialViewToString("~/Areas/WorkerManagement/Views/Worker/_WorkerInRole.cshtml", workerinrole))); }
public ActionResult Edit(int id) { //find the existing workerinrole from database WorkerInRole workerinrole = workerinroleRepository.Find(id); ViewBag.PossibleWorkerRoles = workerroleRepository.All; //return editor view return(View(workerinrole)); }
public ActionResult Create(int workerId) { //create a new instance of workerinrole WorkerInRole workerinrole = new WorkerInRole(); workerinrole.WorkerID = workerId; ViewBag.PossibleWorkerRoles = workerroleRepository.All; //return view result return(View(workerinrole)); }
public ActionResult DetailsAjax(int id) { WorkerInRole workerinrole = workerinroleRepository.Find(id); if (workerinrole == null) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound, "Worker In Role not found")); } return(Content(this.RenderPartialViewToString(Constants.PartialViews.Details, workerinrole))); }
public ActionResult LoadSubProgramEditorAjax(int programID, int workerID) { WorkerInRole workerInRole = new WorkerInRole(); if (IsRegionalAdministrator) { workerInRole.AllSubPrograms = subprogramRepository.FindAllByWordkerID(CurrentLoggedInWorker.ID, programID).ToList(); } else { workerInRole.AllSubPrograms = subprogramRepository.FindAllByProgramID(programID).ToList(); } //workerInRole.AllSubPrograms = subprogramRepository.FindAllByProgramID(programID); //worker.AssignedSubPrograms = workersubprogramRepository.FindAllByWorkerID(workerID); return(Content(this.RenderPartialViewToString("~/Areas/WorkerManagement/Views/Worker/_SubProgram.cshtml", workerInRole))); }
public ActionResult Edit(WorkerInRole workerinrole, int workerId) { workerinrole.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID; try { //validate data if (ModelState.IsValid) { //call the repository function to save in database workerinroleRepository.InsertOrUpdate(workerinrole); workerinroleRepository.Save(); //redirect to list page after successful operation return(RedirectToAction(Constants.Views.Index, new { workerId = workerId })); } else { foreach (var modelStateValue in ViewData.ModelState.Values) { foreach (var error in modelStateValue.Errors) { workerinrole.ErrorMessage = error.ErrorMessage; break; } if (workerinrole.ErrorMessage.IsNotNullOrEmpty()) { break; } } } } catch (CustomException ex) { workerinrole.ErrorMessage = ex.UserDefinedMessage; } catch (Exception ex) { ExceptionManager.Manage(ex); workerinrole.ErrorMessage = Constants.Messages.UnhandelledError; } ViewBag.PossibleWorkerRoles = workerroleRepository.All; //return view with error message if the operation is failed return(View(workerinrole)); }
//protected override void Seed(RepositoryContext context) protected void Seed(RepositoryContext context) { foreach (WorkerRole entity in SeedData.WorkerRoles) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.WorkerRole.Add(entity); } Save(context, "WorkerRole"); foreach (WorkerRolePermission entity in SeedData.WorkerRolePermission) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; context.WorkerRolePermission.Add(entity); } Save(context, "WorkerRolePermission"); foreach (Worker user in SeedData.Workers) { user.ConfirmPassword = user.Password; user.CreateDate = DateTime.Now; user.LastUpdateDate = DateTime.Now; context.Worker.Add(user); } Save(context, "Worker"); foreach (Program entity in SeedData.Program) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Program.Add(entity); } Save(context, "Program"); foreach (SubProgram entity in SeedData.SubProgram) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.SubProgram.Add(entity); } Save(context, "SubProgram"); foreach (Country entity in SeedData.Countries) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Country.Add(entity); } Save(context, "Country"); foreach (ActionStatus entity in SeedData.ActionStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ActionStatus.Add(entity); } Save(context, "ActionStatus"); foreach (ActivityType entity in SeedData.ActivityType) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ActivityType.Add(entity); } Save(context, "ActivityType"); foreach (CaseStatus entity in SeedData.CaseStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.CaseStatus.Add(entity); } Save(context, "CaseStatus"); foreach (ContactMedia entity in SeedData.ContactMedia) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ContactMedia.Add(entity); } Save(context, "ContactMedia"); foreach (ContactMethod entity in SeedData.ContactMethod) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ContactMethod.Add(entity); } Save(context, "ContactMethod"); foreach (Ethnicity entity in SeedData.Ethnicity) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Ethnicity.Add(entity); } Save(context, "Ethnicity"); foreach (Gender entity in SeedData.Genders) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Gender.Add(entity); } Save(context, "Gender"); foreach (HearingSource entity in SeedData.HearingSource) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.HearingSource.Add(entity); } Save(context, "HearingSource"); foreach (IntakeMethod entity in SeedData.IntakeMethod) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.IntakeMethod.Add(entity); } Save(context, "IntakeMethod"); foreach (Language entity in SeedData.Language) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Language.Add(entity); } Save(context, "Language"); foreach (MaritalStatus entity in SeedData.MaritalStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.MaritalStatus.Add(entity); } Save(context, "MaritalStatus"); foreach (MemberStatus entity in SeedData.MemberStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.MemberStatus.Add(entity); } Save(context, "MemberStatus"); foreach (Region entity in SeedData.Region) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Region.Add(entity); } Save(context, "Region"); foreach (State entity in SeedData.States) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.State.Add(entity); } Save(context, "State"); foreach (EmailTemplateCategory entity in SeedData.EmailTemplateCategory) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.EmailTemplateCategory.Add(entity); } Save(context, "EmailTemplateCategory"); foreach (EmailTemplate entity in SeedData.EmailTemplate) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; context.EmailTemplate.Add(entity); } Save(context, "EmailTemplate"); foreach (HighestLevelOfEducation entity in SeedData.HighestLevelOfEducation) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.HighestLevelOfEducation.Add(entity); } Save(context, "HighestLevelOfEducation"); foreach (GPA entity in SeedData.GPA) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.GPA.Add(entity); } Save(context, "GPA"); foreach (AnnualIncome entity in SeedData.AnnualIncome) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.AnnualIncome.Add(entity); } Save(context, "AnnualIncome"); foreach (Savings entity in SeedData.Savings) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Savings.Add(entity); } Save(context, "Savings"); foreach (ServiceProvider entity in SeedData.ExternalServiceProvider) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ServiceProvider.Add(entity); Save(context, "ExternalServiceProvider"); foreach (Service service in SeedData.ServiceProviderServices) { service.ServiceProviderID = entity.ID; service.CreateDate = DateTime.Now; service.LastUpdateDate = DateTime.Now; service.IsActive = true; if (service.Description.IsNullOrEmpty()) { service.Description = entity.Name; } context.Service.Add(service); } Save(context, "Service"); } foreach (ServiceProvider entity in SeedData.InternalServiceProvider) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ServiceProvider.Add(entity); Save(context, "InternalServiceProvider"); foreach (Service service in SeedData.ServiceProviderServices) { service.ServiceProviderID = entity.ID; service.CreateDate = DateTime.Now; service.LastUpdateDate = DateTime.Now; service.IsActive = true; if (service.Description.IsNullOrEmpty()) { service.Description = entity.Name; } context.Service.Add(service); } Save(context, "Service"); } //foreach (Service entity in SeedData.ServiceProviderServices) //{ // entity.CreateDate = DateTime.Now; // entity.LastUpdateDate = DateTime.Now; // entity.IsActive = true; // if (entity.Description.IsNullOrEmpty()) // { // entity.Description = entity.Name; // } // context.Service.Add(entity); //} //Save(context, "Service"); foreach (HousingQuality entity in SeedData.HousingQuality) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.HousingQuality.Add(entity); } Save(context, "HousingQuality"); foreach (ServiceLevelOutcome entity in SeedData.ServiceLevelOutcome) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ServiceLevelOutcome.Add(entity); } Save(context, "ServiceLevelOutcome"); foreach (ImmigrationCitizenshipStatus entity in SeedData.ImmigrationCitizenshipStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ImmigrationCitizenshipStatus.Add(entity); } Save(context, "ImmigrationCitizenshipStatus"); foreach (IndividualStatus entity in SeedData.IndividualStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.IndividualStatus.Add(entity); } Save(context, "IndividualStatus"); foreach (AssessmentType entity in SeedData.AssessmentType) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.AssessmentType.Add(entity); } Save(context, "AssessmentType"); foreach (ProfileType entity in SeedData.ProfileType) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ProfileType.Add(entity); } Save(context, "ProfileType"); foreach (RiskType entity in SeedData.RiskType) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.RiskType.Add(entity); } Save(context, "RiskType"); foreach (FinancialAssistanceCategory entity in SeedData.FinancialAssistanceCategory) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.FinancialAssistanceCategory.Add(entity); } Save(context, "FinancialAssistanceCategory"); foreach (FinancialAssistanceSubCategory entity in SeedData.FinancialAssistanceSubCategory) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.FinancialAssistanceSubCategory.Add(entity); } Save(context, "FinancialAssistanceSubCategory"); foreach (ReasonsForDischarge entity in SeedData.ReasonsForDischarge) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ReasonsForDischarge.Add(entity); } Save(context, "ReasonsForDischarge"); foreach (QualityOfLifeCategory entity in SeedData.QualityOfLifeCategory) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.QualityOfLifeCategory.Add(entity); } Save(context, "QualityOfLifeCategory"); foreach (QualityOfLifeSubCategory entity in SeedData.QualityOfLifeSubCategory) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.QualityOfLifeSubCategory.Add(entity); } Save(context, "QualityOfLifeSubCategory"); foreach (QualityOfLife entity in SeedData.QualityOfLife) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.QualityOfLife.Add(entity); } Save(context, "QualityOfLife"); foreach (RelationshipStatus entity in SeedData.RelationshipStatus) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.RelationshipStatus.Add(entity); } Save(context, "RelationshipStatus"); foreach (ReferralSource entity in SeedData.ReferralSource) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.ReferralSource.Add(entity); } Save(context, "ReferralSource"); foreach (TimeSpent entity in SeedData.TimeSpent) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.TimeSpent.Add(entity); } Save(context, "TimeSpent"); foreach (SmartGoal entity in SeedData.SmartGoal) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.SmartGoal.Add(entity); } Save(context, "SmartGoal"); foreach (Jamatkhana entity in SeedData.Jamatkhana) { entity.CreateDate = DateTime.Now; entity.LastUpdateDate = DateTime.Now; entity.IsActive = true; if (entity.Description.IsNullOrEmpty()) { entity.Description = entity.Name; } context.Jamatkhana.Add(entity); } Save(context, "Jamatkhana"); List <Region> regionList = context.Region.ToList(); List <SubProgram> subProgramList = context.SubProgram.ToList(); foreach (Region region in regionList) { WorkerInRole workerInRole = new WorkerInRole() { CreateDate = DateTime.Now, CreatedByWorkerID = 1, EffectiveFrom = DateTime.Now, EffectiveTo = DateTime.Now.AddYears(50), IsArchived = false, LastUpdateDate = DateTime.Now, LastUpdatedByWorkerID = 1, ProgramID = 1, RegionID = region.ID, WorkerID = 1, WorkerRoleID = 2 }; context.WorkerInRole.Add(workerInRole); context.SaveChanges(); foreach (SubProgram subProgram in subProgramList) { WorkerSubProgram workerSubProgram = new WorkerSubProgram() { CreateDate = DateTime.Now, CreatedByWorkerID = 1, IsArchived = false, LastUpdateDate = DateTime.Now, LastUpdatedByWorkerID = 1, WorkerInRoleID = workerInRole.ID, SubProgramID = subProgram.ID }; context.WorkerSubProgram.Add(workerSubProgram); context.SaveChanges(); } } }
public ViewResult Index([DataSourceRequest(Prefix = "Grid")] DataSourceRequest dsRequest, WorkerInRole searchWorkerInRole, int workerId) { //if(searchWorkerInRole!=null) //{ // if (dsRequest.Filters == null || (dsRequest.Filters != null && dsRequest.Filters.Count == 0)) // { // if (dsRequest.Filters == null) // { // dsRequest.Filters = new List<IFilterDescriptor>(); // } // } //} //DataSourceRequest dsRequestTotalCountQuery = new DataSourceRequest(); //dsRequestTotalCountQuery.Filters = dsRequest.Filters; //DataSourceResult totalCountQuery = workerinroleRepository.All.ToDataSourceResult(dsRequestTotalCountQuery); //ViewData["total"] = totalCountQuery.Data.AsQueryable().Count(); //if (dsRequest.PageSize == 0) //{ // dsRequest.PageSize = Constants.CommonConstants.DefaultPageSize; //} //DataSourceResult result = workerinroleRepository.AllIncluding(workerId,workerinrole => workerinrole.CreatedByWorker, workerinrole => workerinrole.LastUpdatedByWorker, workerinrole => workerinrole.Worker, workerinrole => workerinrole.WorkerRole).ToDataSourceResult(dsRequest); //return View(result.Data); return(View()); }
public ActionResult SaveAjax(WorkerInRole workerinrole) { //id=0 means add operation, update operation otherwise bool isNew = workerinrole.ID == 0; //validate data if (ModelState.IsValid) { try { //if(!isNew) //if (workerinrole.CreatedByWorkerID != CurrentLoggedInWorker.ID && CurrentLoggedInWorkerRoleIDs.IndexOf(1) == -1) //{ // WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action"; // return RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty }); //} workerinrole.SubProgramIDs = Request.Form["SubProgramIDs"].ToString(true).ToStringArray(','); if (workerinrole.SubProgramIDs == null || (workerinrole.SubProgramIDs != null && workerinrole.SubProgramIDs.Length == 0)) { throw new CustomException("Please select at least one sub-program"); } workerinrole.EffectiveFrom = Request.Form["WorkerInRole_EffectiveFrom"].ToDateTime(); workerinrole.EffectiveTo = Request.Form["WorkerInRole_EffectiveTo"].ToDateTime(); if (!workerinrole.EffectiveFrom.IsValidDate()) { throw new CustomException("Please enter effective from date"); } if (!workerinrole.EffectiveTo.IsValidDate()) { throw new CustomException("Please enter effective to date"); } //set the id of the worker who has added/updated this record workerinrole.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID; //call repository function to save the data in database workerinroleRepository.InsertOrUpdate(workerinrole); workerinroleRepository.Save(); //set status message if (isNew) { workerinrole.SuccessMessage = "Worker role has been added successfully"; } else { workerinrole.SuccessMessage = "Worker role has been updated successfully"; } } catch (DbUpdateException ex) { workerinrole.ErrorMessage = "There is a problem adding data to database"; } catch (CustomException ex) { workerinrole.ErrorMessage = ex.UserDefinedMessage; } catch (Exception ex) { ExceptionManager.Manage(ex); workerinrole.ErrorMessage = Constants.Messages.UnhandelledError; } } else { foreach (var modelStateValue in ViewData.ModelState.Values) { foreach (var error in modelStateValue.Errors) { workerinrole.ErrorMessage = error.ErrorMessage; break; } if (workerinrole.ErrorMessage.IsNotNullOrEmpty()) { break; } } } //return the status message in json if (workerinrole.ErrorMessage.IsNotNullOrEmpty()) { return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.Alert, workerinrole) })); } else { return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.Alert, workerinrole) })); } }