コード例 #1
0
        public ActionResult Create(CaseActionNew varCaseGoalNew)
        {
            int sortOrder = 0, count = 0;

            varCaseGoalNew.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
            try
            {
                bool isvalid = true;
                if (ModelState.IsValid)
                {
                    //call the repository function to save in database
                    if (varCaseGoalNew.CaseMemberID.HasValue && varCaseGoalNew.CaseMemberID.Value > 0)
                    {
                        if (!varCaseGoalNew.FamilyAgreeToAction)
                        {
                            varCaseGoalNew.ErrorMessage = "Please confirm family member has agreed to the Action.";
                            isvalid = false;
                        }
                    }
                    else if (varCaseGoalNew.GoalAssigneeRoleID > 0)
                    {
                        if (!varCaseGoalNew.CaseMemberID.HasValue && !varCaseGoalNew.ServiceProviderID.HasValue &&
                            !varCaseGoalNew.WorkerID.HasValue && string.IsNullOrEmpty(varCaseGoalNew.ServiceProviderOther) &&
                            string.IsNullOrEmpty(varCaseGoalNew.AssigneeOther) && string.IsNullOrEmpty(varCaseGoalNew.SubjectMatterExpertOther))
                        {
                            varCaseGoalNew.ErrorMessage = "Please select or enter assignee to (service provider / family member / subject matter expert / other.)";
                            isvalid = false;
                        }
                        if (varCaseGoalNew.GoalAssigneeRoleID == 5 && string.IsNullOrEmpty(varCaseGoalNew.AssigneeOther))
                        {
                            varCaseGoalNew.ErrorMessage = "Please enter assignee to other.)";
                            isvalid = false;
                        }
                        if (varCaseGoalNew.WorkerID == 0 && string.IsNullOrEmpty(varCaseGoalNew.SubjectMatterExpertOther))
                        {
                            varCaseGoalNew.ErrorMessage = "Please enter assignee to other.)";
                            isvalid = false;
                        }
                        if (varCaseGoalNew.ServiceProviderID == 56 && string.IsNullOrEmpty(varCaseGoalNew.ServiceProviderOther))
                        {
                            varCaseGoalNew.ErrorMessage = "Please enter assignee to other.)";
                            isvalid = false;
                        }
                    }
                    if (isvalid)
                    {
                        if (!varCaseGoalNew.ActionStatusID.HasValue)
                        {
                            varCaseGoalNew.ActionStatusID = (int)GoalWorkNote.Inprogress;
                        }


                        count = caseactionnewRepository.CaseGoalActionNewCountByCaseID(varCaseGoalNew.CaseID);

                        if (count >= 0)
                        {
                            sortOrder = count + 1;
                        }

                        varCaseGoalNew.SortOrder = sortOrder;

                        caseactionnewRepository.InsertOrUpdate(varCaseGoalNew);
                        caseactionnewRepository.Save();

                        if (varCaseGoalNew.GoalActionWorkNote.ContactMethodID > 0)
                        {
                            varCaseGoalNew.GoalActionWorkNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                            varCaseGoalNew.GoalActionWorkNote.IsAction     = true;
                            varCaseGoalNew.GoalActionWorkNote.CaseGoalID   = varCaseGoalNew.CaseGoalID;
                            varCaseGoalNew.GoalActionWorkNote.CaseActionID = varCaseGoalNew.ID;

                            varCaseGoalNew.GoalActionWorkNote.StatusID = (int)GoalWorkNote.Inprogress;

                            goalActionWorkNoteRepository.InsertOrUpdate(varCaseGoalNew.GoalActionWorkNote);
                            goalActionWorkNoteRepository.Save();
                        }

                        return(RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseActionNew, new { caseId = varCaseGoalNew.CaseID, caseGoalId = varCaseGoalNew.CaseGoalID }));
                    }
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            varCaseGoalNew.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (varCaseGoalNew.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }

                    //return RedirectToAction(Constants.Actions.Create, Constants.Controllers.CaseActionNew, new { caseId = varCaseGoalNew.CaseID, caseGoalId = varCaseGoalNew.CaseGoalID });
                    //varCaseGoalNew.ErrorMessage = "Record not saved";
                    //ViewBag.MessageErr = "Record not saved";
                    //return RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseGoalNew, new { caseID = varCaseGoalNew.CaseID });
                }
            }
            catch (CustomException ex)
            {
                varCaseGoalNew.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                varCaseGoalNew.ErrorMessage = Constants.Messages.UnhandelledError;
            }

            return(View(varCaseGoalNew));
        }
コード例 #2
0
        public ActionResult Create(CaseGoalNew varCaseGoalNew)
        {
            int sortOrder = 0, count = 0;

            try
            {
                varCaseGoalNew.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                //validate data
                if (ModelState.IsValid)
                {
                    if (varCaseGoalNew.Family == "Family")
                    {
                        varCaseGoalNew.IsFamily       = true;
                        varCaseGoalNew.IsFamilyMember = false;
                    }
                    else
                    {
                        varCaseGoalNew.IsFamily       = false;
                        varCaseGoalNew.IsFamilyMember = true;
                    }

                    //call the repository function to save in database
                    if (!varCaseGoalNew.GoalStatusID.HasValue)
                    {
                        varCaseGoalNew.GoalStatusID = (int)GoalWorkNote.Inprogress;
                    }


                    count = caseGoalNewRepository.CaseGoalNewCountByCaseID(varCaseGoalNew.CaseID);

                    if (count >= 0)
                    {
                        sortOrder = count + 1;
                    }

                    varCaseGoalNew.SortOrder = sortOrder;

                    caseGoalNewRepository.InsertOrUpdate(varCaseGoalNew);
                    caseGoalNewRepository.Save();

                    if (varCaseGoalNew.GoalActionWorkNote.ContactMethodID > 0)
                    {
                        varCaseGoalNew.GoalActionWorkNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        varCaseGoalNew.GoalActionWorkNote.CaseGoalID            = varCaseGoalNew.ID;

                        varCaseGoalNew.GoalActionWorkNote.StatusID = (int)GoalWorkNote.Inprogress;
                        varCaseGoalNew.GoalActionWorkNote.IsGoal   = true;
                        varCaseGoalNew.GoalActionWorkNote.IsAction = false;
                        goalActionWorkNoteRepository.InsertOrUpdate(varCaseGoalNew.GoalActionWorkNote);
                        goalActionWorkNoteRepository.Save();
                    }

                    return(RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseSummary, new { caseID = varCaseGoalNew.CaseID }));
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            varCaseGoalNew.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (varCaseGoalNew.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                    varCaseGoalNew.ErrorMessage = "Record not saved";
                    ViewBag.MessageErr          = "Record not saved";
                    return(RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseGoalNew, new { caseID = varCaseGoalNew.CaseID }));
                }
            }
            catch (CustomException ex)
            {
                varCaseGoalNew.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                varCaseGoalNew.ErrorMessage = Constants.Messages.UnhandelledError;
            }

            return(View(varCaseGoalNew));
        }