// GET: CaseManagement/CaseActionNew public ActionResult Edit(int caseId, int caseGoalId, int caseActionId) { CaseActionNew caseactionnew = new CaseActionNew(); if (caseGoalId > 0) { //find an existing casemember from database Case varCase = caseRepository.Find(Convert.ToInt32(caseId)); ViewBag.DisplayID = varCase.DisplayID; ViewBag.CaseID = caseId; caseactionnew = caseactionnewRepository.Find(caseActionId); caseactionnew.OLDCaseMemberID = caseactionnew.CaseMemberID; caseactionnew.OLDWorkerID = caseactionnew.WorkerID; caseactionnew.OLDServiceProviderID = caseactionnew.ServiceProviderID; caseactionnew.OLDAssigneeOther = caseactionnew.AssigneeOther; caseactionnew.OLDSubjectMatterExpertOther = caseactionnew.SubjectMatterExpertOther; if (caseactionnew.ServiceProviderID == 56) { caseactionnew.ServiceProviderOther = caseactionnew.AssigneeOther; } caseactionnew.RegionID = varCase.RegionID; caseactionnew.CaseID = caseId; bool hasAccess = workerroleactionpermissionnewRepository.HasPermission(Convert.ToInt32(caseId), CurrentLoggedInWorkerRoleIDs, CurrentLoggedInWorker.ID, varCase.ProgramID, varCase.RegionID, varCase.SubProgramID, varCase.JamatkhanaID, Constants.Areas.CaseManagement, Constants.Controllers.CaseMember, Constants.Actions.Edit, true); if (!hasAccess) { WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action"; return(RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty })); } //casegoalnew = caseGoalNewRepository.Find(caseGoalId); CaseGoalEditVM casegoalnew = caseGoalNewRepository.GetCaseGoal(caseGoalId); if (casegoalnew == null) { //throw an exception if id is provided but data does not exist in database return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound, "Case goal not found")); } else { } } else { //create a new instance if id is not provided //casegoalnew = new CaseGoalNew(); //casegoalnew.CaseID = caseId.ToInteger(true); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound, "Case goal not found")); } ViewBag.ContactMediaList = contactmediaRepository.AllActiveForDropDownList; caseactionnew.GoalActionWorkNote = new GoalActionWorkNote(); return(View("Create", caseactionnew)); }
public bool UpdateDetails(CaseGoalEditVM casegoal) { var goal = context.CaseGoalNew.Find(casegoal.ID); if (goal != null) { goal.PriorityTypeID = casegoal.PriorityTypeID; goal.GoalStatusID = casegoal.GoalStatusID; goal.LastUpdateDate = DateTime.Now; context.Entry(goal).State = System.Data.Entity.EntityState.Modified; Save(); return(true); } return(false); }
public ActionResult EditGoalDetails(CaseGoalEditVM casegoal) { //validate data if (ModelState.IsValid) { try { bool isupdated = caseGoalNewRepository.UpdateDetails(casegoal); if (casegoal.GoalActionWorkNote.ContactMethodID > 0) { //if (casegoal.GoalActionWorkNote.IsGoal == true) //{ // //var Ids = Request.Url.Segments.Last(); // //GoalActionWorkNote.CaseGoalID = Convert.ToInt32(Ids); // GoalActionWorkNote.CaseActionID = GoalActionWorkNote.CaseActionID; //} //if (GoalActionWorkNote.IsAction == true) //{ // GoalActionWorkNote.CaseActionID = GoalActionWorkNote.CaseActionID; //} casegoal.GoalActionWorkNote.CaseGoalID = casegoal.CaseGoalID; casegoal.GoalActionWorkNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID; casegoal.GoalActionWorkNote.StatusID = (int)GoalWorkNote.Inprogress; goalActionWorkNoteRepository.InsertOrUpdate(casegoal.GoalActionWorkNote); goalActionWorkNoteRepository.Save(); //GoalActionWorkNote.SuccessMessage = "Goal details updated successfully."; } if (isupdated) { casegoal.SuccessMessage = "Goal details updated successfully."; } else { casegoal.SuccessMessage = "Goal details not found."; } } catch (DbUpdateException ex) { casegoal.ErrorMessage = ex.Message; } catch (CustomException ex) { casegoal.ErrorMessage = ex.UserDefinedMessage; } catch (Exception ex) { ExceptionManager.Manage(ex); casegoal.ErrorMessage = Constants.Messages.UnhandelledError; } } else { foreach (var modelStateValue in ViewData.ModelState.Values) { foreach (var error in modelStateValue.Errors) { casegoal.ErrorMessage = error.ErrorMessage; break; } if (casegoal.ErrorMessage.IsNotNullOrEmpty()) { break; } } } //return the status message in json if (casegoal.ErrorMessage.IsNotNullOrEmpty()) { return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.Alert, casegoal) })); } else { return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.Alert, casegoal) })); } }