Ejemplo n.º 1
0
        public ActionResult Create(CaseMember casemember, int caseId)
        {
            if (casemember.CaseID == 0 && caseId > 0)
            {
                casemember.CaseID = caseId;
            }
            casemember.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
            try
            {
                //validate data
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(casemember.CaseWorkerNote.Note) || casemember.CaseWorkerNote.NoteDate != null ||
                        casemember.CaseWorkerNote.TimeSpentHours != null || casemember.CaseWorkerNote.TimeSpentMinutes != null ||
                        (casemember.CaseWorkerNote.ContactMethodID != null && casemember.CaseWorkerNote.ContactMethodID > 0))
                    {
                        var isnoteerror = false;

                        if (string.IsNullOrEmpty(casemember.CaseWorkerNote.Note))
                        {
                            ModelState.AddModelError("", "Please enter work note.");
                            isnoteerror = true;
                        }

                        if (casemember.CaseWorkerNote.NoteDate == null)
                        {
                            ModelState.AddModelError("", "Please enter not date");
                            isnoteerror = true;
                        }

                        if ((casemember.CaseWorkerNote.TimeSpentHours == null || casemember.CaseWorkerNote.TimeSpentHours == 0) &&
                            (casemember.CaseWorkerNote.TimeSpentMinutes == null || casemember.CaseWorkerNote.TimeSpentMinutes == 0))
                        {
                            ModelState.AddModelError("", "Please enter time spent");
                            isnoteerror = true;
                        }

                        if (casemember.CaseWorkerNote.ContactMethodID == null || casemember.CaseWorkerNote.ContactMethodID == 0)
                        {
                            ModelState.AddModelError("", "Please select contact method");
                            isnoteerror = true;
                        }
                        if (isnoteerror)
                        {
                            var varCase = caseRepository.Find(caseId);
                            if (varCase != null)
                            {
                                ViewBag.DisplayID = varCase.DisplayID;
                            }
                            ViewBag.CaseID            = caseId;
                            casemember.EnrollDate     = DateTime.Now;
                            casemember.MemberStatusID = 1;
                            casemember.IsActive       = true;
                            return(View(casemember));
                        }
                    }

                    casememberRepository.InsertOrUpdate(casemember);
                    casememberRepository.Save();

                    if (casemember.CaseWorkerNote.ContactMethodID > 0)
                    {
                        casemember.CaseWorkerNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        casemember.CaseWorkerNote.CaseID = casemember.CaseID;
                        //caseMember.CaseWorkerNote.CaseStatusID = varCase.CaseStatusID;
                        //caseMember.CaseWorkerNote.ProgramID = varCase.ProgramID;
                        casemember.CaseWorkerNote.IsFamily                 = true;
                        casemember.CaseWorkerNote.IsFamilyMember           = false;
                        casemember.CaseWorkerNote.WorkerNoteActivityTypeID = (int)WorkerNoteActivityType.CaseIndividual;
                        //varCase.CaseWorkerNote.NoteDate = Convert.ToDateTime(varCase.ContactDate);
                        caseWorkerNoteRepository.InsertOrUpdate(casemember.CaseWorkerNote);
                        caseWorkerNoteRepository.Save();
                    }
                    //return RedirectToAction(Constants.Views.Index, new { caseId = caseMember.CaseID });
                    return(RedirectToAction(Constants.Views.Edit, new { id = casemember.ID, caseId = casemember.CaseID }));
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            casemember.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (casemember.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                }
            }
            catch (CustomException ex)
            {
                casemember.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                casemember.ErrorMessage = Constants.Messages.UnhandelledError;
            }
            //return view with error message if operation is failed
            return(View(casemember));
        }
Ejemplo n.º 2
0
        public ActionResult SaveAjax(CaseWorkerNote caseWorkerNote)
        {
            //id=0 means add operation, update operation otherwise
            bool isNew = caseWorkerNote.ID == 0;

            caseWorkerNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;

            //validate data
            if (ModelState.IsValid)
            {
                try
                {
                    if (!string.IsNullOrEmpty(caseWorkerNote.Note) || caseWorkerNote.NoteDate != null ||
                        caseWorkerNote.TimeSpentHours != null || caseWorkerNote.TimeSpentMinutes != null ||
                        (caseWorkerNote.ContactMethodID != null && caseWorkerNote.ContactMethodID > 0) ||
                        !string.IsNullOrEmpty(caseWorkerNote.Family))
                    {
                        var    isnoteerror = false;
                        string errmsg      = string.Empty;

                        if (string.IsNullOrEmpty(caseWorkerNote.Note))
                        {
                            errmsg     += "Please enter work note. <br/>";
                            isnoteerror = true;
                        }

                        if (caseWorkerNote.NoteDate == null)
                        {
                            errmsg     += "Please enter not date. <br/>";
                            isnoteerror = true;
                        }

                        if ((caseWorkerNote.TimeSpentHours == null || caseWorkerNote.TimeSpentHours == 0) &&
                            (caseWorkerNote.TimeSpentMinutes == null || caseWorkerNote.TimeSpentMinutes == 0))
                        {
                            errmsg     += "Please enter time spent. <br/>";
                            isnoteerror = true;
                        }

                        if (caseWorkerNote.ContactMethodID == null || caseWorkerNote.ContactMethodID == 0)
                        {
                            errmsg     += "Please select contact method. <br/>";
                            isnoteerror = true;
                        }
                        if (isnoteerror)
                        {
                            CustomException ex = new CustomException(CustomExceptionType.CommonServerError, errmsg);
                            throw ex;
                        }
                    }

                    if (caseWorkerNote.Family == "Family")
                    {
                        caseWorkerNote.IsFamily       = true;
                        caseWorkerNote.IsFamilyMember = false;
                    }
                    else
                    {
                        caseWorkerNote.IsFamily       = false;
                        caseWorkerNote.IsFamilyMember = true;
                    }

                    caseWorkerNote.WorkerNoteActivityTypeID = (int)eCMS.Shared.WorkerNoteActivityType.WorkNote;
                    //call repository function to save the data in database
                    caseWorkerNoteRepository.InsertOrUpdate(caseWorkerNote);
                    caseWorkerNoteRepository.Save();
                    //set status message
                    if (isNew)
                    {
                        caseWorkerNote.SuccessMessage = "Work Note has been added successfully";
                    }
                    else
                    {
                        caseWorkerNote.SuccessMessage = "Work Note has been updated successfully";
                    }
                }
                catch (CustomException ex)
                {
                    caseWorkerNote.ErrorMessage = ex.UserDefinedMessage;
                }
                catch (Exception ex)
                {
                    ExceptionManager.Manage(ex);
                    caseWorkerNote.ErrorMessage = Constants.Messages.UnhandelledError;
                }
            }
            else
            {
                foreach (var modelStateValue in ViewData.ModelState.Values)
                {
                    foreach (var error in modelStateValue.Errors)
                    {
                        caseWorkerNote.ErrorMessage = error.ErrorMessage;
                        break;
                    }
                    if (caseWorkerNote.ErrorMessage.IsNotNullOrEmpty())
                    {
                        break;
                    }
                }
            }
            //return the status message in json
            if (caseWorkerNote.ErrorMessage.IsNotNullOrEmpty())
            {
                return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, caseWorkerNote) }));
            }
            else
            {
                return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, caseWorkerNote) }));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Create(InitialAssessmentVM iniass, int caseId)
        {
            if (iniass.CaseID == 0 && caseId > 0)
            {
                iniass.CaseID = caseId;
            }
            try
            {
                //validate data
                if (ModelState.IsValid)
                {
                    if (iniass.CaseWorkerNote.ContactMethodID > 0)
                    {
                        iniass.CaseWorkerNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        iniass.CaseWorkerNote.CaseID                   = iniass.CaseID;
                        iniass.CaseWorkerNote.IsFamily                 = true;
                        iniass.CaseWorkerNote.IsFamilyMember           = false;
                        iniass.CaseWorkerNote.WorkerNoteActivityTypeID = (int)eCMS.Shared.WorkerNoteActivityType.CaseInitialAssessment;
                        caseWorkerNoteRepository.InsertOrUpdate(iniass.CaseWorkerNote);
                        caseWorkerNoteRepository.Save();
                    }
                    if (iniass.CaseHouseholdIncome.IncomeRangeID > 0)
                    {
                        iniass.CaseHouseholdIncome.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        iniass.CaseHouseholdIncome.CaseID          = iniass.CaseID;
                        iniass.CaseHouseholdIncome.IsInitialIncome = false;
                        caseHouseholdIncomeRepository.InsertOrUpdate(iniass.CaseHouseholdIncome);
                        caseHouseholdIncomeRepository.Save();
                    }
                    //return RedirectToAction(Constants.Views.Index, new { caseId = caseMember.CaseID });

                    return(RedirectToAction(Constants.Views.Index, new { caseid = iniass.CaseID }));
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            iniass.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (iniass.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                }
            }
            catch (CustomException ex)
            {
                iniass.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                iniass.ErrorMessage = Constants.Messages.UnhandelledError;
            }
            //return view with error message if operation is failed
            iniass.AssesmentIndicators    = caseInitialAssessmentRepository.GetAllIndicators();
            iniass.CaseInitialAssessment  = caseInitialAssessmentRepository.GetCaseAssessment(iniass.CaseID);
            iniass.CaseAssessmentReviewed = caseInitialAssessmentRepository.CaseAssessmentReviewed(iniass.CaseID);

            return(View("Index", iniass));
        }
Ejemplo n.º 4
0
        public ActionResult Create(CaseStatusHistory varCaseStatusHistory)
        {
            try
            {
                varCaseStatusHistory.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                //validate data
                if (ModelState.IsValid)
                {
                    //call the repository function to save in database
                    caseStatusHistoryRepository.InsertOrUpdate(varCaseStatusHistory);
                    caseStatusHistoryRepository.Save();

                    varCaseStatusHistory.CaseHouseholdIncome.IncomeRanges = incomeRangeRepository.GetAll().ToList();

                    if (varCaseStatusHistory.CaseHouseholdIncome.NoOfMembers > 0)
                    {
                        varCaseStatusHistory.CaseHouseholdIncome.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        varCaseStatusHistory.CaseHouseholdIncome.CaseID = varCaseStatusHistory.CaseID;
                        caseHouseholdIncomeRepository.InsertOrUpdate(varCaseStatusHistory.CaseHouseholdIncome);
                        caseHouseholdIncomeRepository.Save();
                    }

                    if (varCaseStatusHistory.CaseWorkerNote.ContactMethodID > 0)
                    {
                        varCaseStatusHistory.CaseWorkerNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;

                        varCaseStatusHistory.CaseWorkerNote.CaseID                   = varCaseStatusHistory.CaseID;
                        varCaseStatusHistory.CaseWorkerNote.CaseStatusID             = varCaseStatusHistory.StatusID;
                        varCaseStatusHistory.CaseWorkerNote.WorkerNoteActivityTypeID = (int)WorkerNoteActivityType.EditCase;
                        varCaseStatusHistory.CaseWorkerNote.IsFamily                 = true;
                        caseWorkerNoteRepository.InsertOrUpdate(varCaseStatusHistory.CaseWorkerNote);
                        caseWorkerNoteRepository.Save();
                    }

                    caseRepository.UpdateCaseStatus(varCaseStatusHistory.CaseID, varCaseStatusHistory.StatusID, CurrentLoggedInWorker.ID);
                    caseRepository.Save();

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

            return(View(varCaseStatusHistory));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(CaseHouseholdIncome incomemodel)
        {
            incomemodel.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;

            try
            {
                //validate data
                if (ModelState.IsValid)
                {
                    //if all blank then move forward
                    //if any one entered then check all entered
                    bool allentered = true;

                    if (incomemodel.NoOfMembers == 0 || incomemodel.IncomeRangeID == 0)
                    {
                        incomemodel.IncomeRanges = incomeRangeRepository.GetAll().ToList();
                        if (incomemodel.NoOfMembers == 0)
                        {
                            ModelState.AddModelError("", "Please enter No. of members");
                        }
                        if (incomemodel.IncomeRangeID == 0)
                        {
                            ModelState.AddModelError("", "Please select income range");
                        }
                        return(View(incomemodel));
                        //CustomException ex = new CustomException(CustomExceptionType.CommonServerError, "Please enter No. of members and income range.");
                        //throw ex;
                    }
                    if (!string.IsNullOrEmpty(incomemodel.CaseWorkerNote.Note) || incomemodel.CaseWorkerNote.NoteDate != null ||
                        incomemodel.CaseWorkerNote.TimeSpentHours != null || incomemodel.CaseWorkerNote.TimeSpentMinutes != null ||
                        (incomemodel.CaseWorkerNote.ContactMethodID != null && incomemodel.CaseWorkerNote.ContactMethodID > 0))
                    {
                        incomemodel.IncomeRanges = incomeRangeRepository.GetAll().ToList();
                        var isnoteerror = false;

                        if (string.IsNullOrEmpty(incomemodel.CaseWorkerNote.Note))
                        {
                            ModelState.AddModelError("", "Please enter work note.");
                            isnoteerror = true;
                        }

                        if (incomemodel.CaseWorkerNote.NoteDate == null)
                        {
                            ModelState.AddModelError("", "Please enter not date");
                            isnoteerror = true;
                        }

                        if ((incomemodel.CaseWorkerNote.TimeSpentHours == null || incomemodel.CaseWorkerNote.TimeSpentHours == 0) &&
                            (incomemodel.CaseWorkerNote.TimeSpentMinutes == null || incomemodel.CaseWorkerNote.TimeSpentMinutes == 0))
                        {
                            ModelState.AddModelError("", "Please enter time spent");
                            isnoteerror = true;
                        }

                        if (incomemodel.CaseWorkerNote.ContactMethodID == null || incomemodel.CaseWorkerNote.ContactMethodID == 0)
                        {
                            ModelState.AddModelError("", "Please select contact method");
                            isnoteerror = true;
                        }
                        if (isnoteerror)
                        {
                            return(View(incomemodel));
                        }
                    }

                    if (incomemodel.ID == 0)
                    {
                        incomemodel.IsInitialIncome = true;
                    }
                    else
                    {
                        incomemodel.ID = 0;
                        incomemodel.IsInitialIncome = false;
                    }

                    caseHouseholdIncomeRepository.InsertOrUpdate(incomemodel);
                    caseHouseholdIncomeRepository.Save();

                    if (incomemodel.CaseWorkerNote.ContactMethodID > 0)
                    {
                        incomemodel.CaseWorkerNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        incomemodel.CaseWorkerNote.CaseID = incomemodel.CaseID;
                        //incomemodel.CaseWorkerNote.CaseStatusID = incomemodel.CaseStatusID;
                        //incomemodel.CaseWorkerNote.ProgramID = incomemodel.ProgramID;
                        //varCase.CaseWorkerNote.NoteDate = Convert.ToDateTime(varCase.ContactDate);
                        incomemodel.CaseWorkerNote.IsFamily                 = true;
                        incomemodel.CaseWorkerNote.IsFamilyMember           = false;
                        incomemodel.CaseWorkerNote.WorkerNoteActivityTypeID = (int)WorkerNoteActivityType.EditHouseholdIncome;

                        caseWorkerNoteRepository.InsertOrUpdate(incomemodel.CaseWorkerNote);
                        caseWorkerNoteRepository.Save();
                    }
                    return(RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseSummary, new { caseID = incomemodel.CaseID }));
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            incomemodel.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (incomemodel.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                }
            }
            catch (CustomException ex)
            {
                incomemodel.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                incomemodel.ErrorMessage = Constants.Messages.UnhandelledError;
            }
            return(View(incomemodel));
        }
        public ActionResult Create(CaseWorker caseworker, int caseId)
        {
            caseworker.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
            caseworker.CaseID = caseId;
            try
            {
                //validate data
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(caseworker.CaseWorkerNote.Note) || caseworker.CaseWorkerNote.NoteDate != null ||
                        caseworker.CaseWorkerNote.TimeSpentHours != null || caseworker.CaseWorkerNote.TimeSpentMinutes != null ||
                        (caseworker.CaseWorkerNote.ContactMethodID != null && caseworker.CaseWorkerNote.ContactMethodID > 0))
                    {
                        var isnoteerror = false;

                        if (string.IsNullOrEmpty(caseworker.CaseWorkerNote.Note))
                        {
                            ModelState.AddModelError("", "Please enter work note.");
                            isnoteerror = true;
                        }

                        if (caseworker.CaseWorkerNote.NoteDate == null)
                        {
                            ModelState.AddModelError("", "Please enter not date");
                            isnoteerror = true;
                        }

                        if ((caseworker.CaseWorkerNote.TimeSpentHours == null || caseworker.CaseWorkerNote.TimeSpentHours == 0) &&
                            (caseworker.CaseWorkerNote.TimeSpentMinutes == null || caseworker.CaseWorkerNote.TimeSpentMinutes == 0))
                        {
                            ModelState.AddModelError("", "Please enter time spent");
                            isnoteerror = true;
                        }

                        if (caseworker.CaseWorkerNote.ContactMethodID == null || caseworker.CaseWorkerNote.ContactMethodID == 0)
                        {
                            ModelState.AddModelError("", "Please select contact method");
                            isnoteerror = true;
                        }
                        if (isnoteerror)
                        {
                            Case varCase = caseRepository.Find(caseId);

                            List <SelectListItem> workerList = workerRepository.NewFindAllPossible(varCase.ProgramID, varCase.RegionID, varCase.SubProgramID);
                            if (workerList == null || (workerList != null && workerList.Count == 0))
                            {
                                caseworker.ErrorMessage = "There is no worker found for Program:" + varCase.Program.Name + ", Region:" + varCase.Region.Name + ", Sub-Program:" + varCase.SubProgram.Name;
                            }
                            ViewBag.PossibleWorkerList = workerList;
                            return(View(caseworker));
                        }
                    }

                    //call the repository function to save in database
                    caseworker.IsActive = true;
                    caseworkerRepository.InsertOrUpdate(caseworker);
                    caseworkerRepository.Save();
                    if (caseworker.CaseWorkerNote.ContactMethodID > 0)
                    {
                        caseworker.CaseWorkerNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                        caseworker.CaseWorkerNote.CaseID = caseworker.CaseID;
                        //caseMember.CaseWorkerNote.CaseStatusID = varCase.CaseStatusID;
                        //caseMember.CaseWorkerNote.ProgramID = varCase.ProgramID;
                        caseworker.CaseWorkerNote.IsFamily                 = true;
                        caseworker.CaseWorkerNote.IsFamilyMember           = false;
                        caseworker.CaseWorkerNote.WorkerNoteActivityTypeID = (int)WorkerNoteActivityType.CaseWorker;
                        //varCase.CaseWorkerNote.NoteDate = Convert.ToDateTime(varCase.ContactDate);
                        caseWorkerNoteRepository.InsertOrUpdate(caseworker.CaseWorkerNote);
                        caseWorkerNoteRepository.Save();
                    }
                    //redirect to list page after successful operation
                    //return RedirectToAction(Constants.Views.Index, new { caseId = caseId });
                    return(RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseSummary, new { caseID = caseId }));
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            caseworker.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (caseworker.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                }
            }
            catch (CustomException ex)
            {
                caseworker.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                caseworker.ErrorMessage = Constants.Messages.UnhandelledError;
            }
            ViewBag.PossibleCreatedByWorkers     = workerRepository.All;
            ViewBag.PossibleLastUpdatedByWorkers = workerRepository.All;
            ViewBag.PossibleWorkers = workerRepository.All;
            return(View(caseworker));
        }