Exemple #1
0
        public JsonResult GetSentenseById(int Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                PCMPresentenceModel Model = new PCMPresentenceModel();

                //initialise view model
                PCMPresentenceDetailsViewModel vm = new PCMPresentenceDetailsViewModel();

                vm.CommunityBasedOptions_List     = Model.GetCommunityBasedOption();
                vm.SupendedPostponedSentence_List = Model.GetSupendedPostponedSentence();
                vm.CaseStatus_List          = Model.GetCaseStatus();//..................?
                vm.RestorectiveJustice_List = Model.GetRestorectiveJustice();
                vm.ProgrammeType_List       = Model.GetProgrammeType();
                vm.Programme_List           = Model.GetProgramme();
                vm.Imprisoment_List         = Model.GetImprisoment();//..................?
                vm.Department_List          = Model.GetDepartment();
                vm.Court_List    = Model.GetAllCourt();
                vm.Province_List = Model.GetAllProvinces();
                vm.District_List = Model.GetAllDistrict();

                ViewBag.CommunityBasedOptions     = new SelectList(db.apl_PCM_Community_Based_Options.ToList(), "Community_Based_Options_Id", "Description");
                ViewBag.SupendedPostponedSentence = new SelectList(db.apl_PCM_Supended_Postponed_Sentence.ToList(), "Suspended_Postponed_Sentence_Id", "Description");
                ViewBag.CaseStatus = new SelectList(db.apl_PCM_Case_Status.ToList(), "PCM_Case_Status_Id", "Description");

                ViewBag.RestorectiveJustice = new SelectList(db.apl_Restorective_Justice_Types.ToList(), "Restorective_Justice_Option_Id", "Description");
                ViewBag.ProgrammeType       = new SelectList(db.apl_Programme_Type.ToList(), "Programme_Type_Id", "Description");
                ViewBag.Programme           = new SelectList(db.apl_Programmes.ToList(), "Programme_Type_Id", "Programme_Name");

                ViewBag.Imprisoment = new SelectList(db.apl_PCM_Imprisoment.ToList(), "Imprisoment_Id", "Description");
                ViewBag.Department  = new SelectList(db.apl_Department.ToList(), "Department_Id", "Description");
                ViewBag.Province    = new SelectList(db.Provinces.ToList(), "Province_Id", "Description");
                ViewBag.District    = new SelectList(db.Districts.ToList(), "District_Id", "Description");
                ViewBag.Court       = new SelectList(db.Courts.ToList(), "Court_Id", "Description");

                vm = Model.GetPCMSentenseOnEditDetails(Id);
                string value = string.Empty;
                value = JsonConvert.SerializeObject(vm, Formatting.Indented, new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });
                return(Json(value, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        public ActionResult SentenseList()
        {
            //get current username
            string loginName = User.Identity.Name;

            Session["LoginName"] = loginName;
            int caseid = Convert.ToInt32(Session["IntakeassId"]);

            var currentUser  = (User)Session["CurrentUser"];
            var userProvince = -1;
            var userId       = 0;

            if (currentUser != null)
            {
                userId = currentUser.User_Id;
                if (currentUser.Employees.Any())
                {
                    userProvince = currentUser.Employees.First().apl_Service_Office.apl_Local_Municipality.District.Province_Id;
                }
                if (currentUser.apl_Social_Worker.Any())
                {
                    userProvince = currentUser.apl_Social_Worker.First().apl_Service_Office.apl_Local_Municipality.District.Province_Id;
                }
            }
            string ClientRef = Convert.ToString(Session["ClientRef"]);

            ViewBag.ModuleRef = ClientRef;

            PCMPresentenceModel Model = new PCMPresentenceModel();

            //initialise view model
            PCMPresentenceDetailsViewModel VM = new PCMPresentenceDetailsViewModel();

            VM.CommunityBasedOptions_List     = Model.GetCommunityBasedOption();
            VM.SupendedPostponedSentence_List = Model.GetSupendedPostponedSentence();
            VM.CaseStatus_List          = Model.GetCaseStatus();//..................?
            VM.RestorectiveJustice_List = Model.GetRestorectiveJustice();
            VM.ProgrammeType_List       = Model.GetProgrammeType();
            VM.Programme_List           = Model.GetProgramme();
            VM.Imprisoment_List         = Model.GetImprisoment();//..................?
            VM.Department_List          = Model.GetDepartment();
            VM.Court_List    = Model.GetAllCourt();
            VM.Province_List = Model.GetAllProvinces();
            VM.District_List = Model.GetAllDistrict();

            ViewBag.CommunityBasedOptions     = new SelectList(db.apl_PCM_Community_Based_Options.ToList(), "Community_Based_Options_Id", "Description");
            ViewBag.SupendedPostponedSentence = new SelectList(db.apl_PCM_Supended_Postponed_Sentence.ToList(), "Suspended_Postponed_Sentence_Id", "Description");
            ViewBag.CaseStatus = new SelectList(db.apl_PCM_Case_Status.ToList(), "PCM_Case_Status_Id", "Description");

            ViewBag.RestorectiveJustice = new SelectList(db.apl_Restorective_Justice_Types.ToList(), "Restorective_Justice_Option_Id", "Description");
            ViewBag.ProgrammeType       = new SelectList(db.apl_Programme_Type.ToList(), "Programme_Type_Id", "Description");
            ViewBag.Programme           = new SelectList(db.apl_Programmes.ToList(), "Programme_Type_Id", "Programme_Name");

            ViewBag.Imprisoment = new SelectList(db.apl_PCM_Imprisoment.ToList(), "Imprisoment_Id", "Description");
            ViewBag.Department  = new SelectList(db.apl_Department.ToList(), "Department_Id", "Description");
            ViewBag.Province    = new SelectList(db.Provinces.ToList(), "Province_Id", "Description");
            ViewBag.District    = new SelectList(db.Districts.ToList(), "District_Id", "Description");
            ViewBag.Court       = new SelectList(db.Courts.ToList(), "Court_Id", "Description");

            return(PartialView(VM));
        }
Exemple #3
0
        public ActionResult GetPCMPresentense()
        {
            int intassid = Convert.ToInt32(Session["IntakeassId"]);
            // get current username
            string loginName = User.Identity.Name;

            Session["LoginName"] = loginName;
            var currentUser  = (User)Session["CurrentUser"];
            var userProvince = -1;
            var userId       = 0;

            if (currentUser != null)
            {
                userId = currentUser.User_Id;
                if (currentUser.Employees.Any())
                {
                    userProvince = currentUser.Employees.First().apl_Service_Office.apl_Local_Municipality.District.Province_Id;
                }
                if (currentUser.apl_Social_Worker.Any())
                {
                    userProvince = currentUser.apl_Social_Worker.First().apl_Service_Office.apl_Local_Municipality.District.Province_Id;
                }
            }
            PCMCaseModel caseModelC = new PCMCaseModel();

            string ClientRef = Convert.ToString(Session["ClientRef"]);

            ViewBag.ModuleRef = ClientRef;

            PCMPresentenceModel Model = new PCMPresentenceModel();
            //initialise view model
            PCMPresentenceDetailsViewModel VM = new PCMPresentenceDetailsViewModel();

            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                int Presentenseid = Model.GetPCMPresentenseByassId(intassid);
                if (Presentenseid != 0)
                {
                    VM = Model.GetPresentenseList(Presentenseid);

                    //populate dropdown lists

                    VM.CommunityBasedOptions_List     = Model.GetCommunityBasedOption();
                    VM.SupendedPostponedSentence_List = Model.GetSupendedPostponedSentence();
                    VM.CaseStatus_List          = Model.GetCaseStatus();//..................?
                    VM.RestorectiveJustice_List = Model.GetRestorectiveJustice();
                    VM.ProgrammeType_List       = Model.GetProgrammeType();
                    VM.Programme_List           = Model.GetProgramme();
                    VM.Imprisoment_List         = Model.GetImprisoment();//..................?
                    VM.Department_List          = Model.GetDepartment();
                    VM.Court_List    = Model.GetAllCourt();
                    VM.Province_List = Model.GetAllProvinces();
                    VM.District_List = Model.GetAllDistrict();


                    if (Convert.ToInt32(Model.GetPresentenseList(Presentenseid).Court_id) != 0)
                    {
                        int Courtid = Convert.ToInt32(Model.GetPresentenseList(Presentenseid).Court_id);
                        ViewBag.Court = db.Courts.Find(Courtid).Description;

                        //Get District using the court..........................................
                        int DistrictId = (from k in db.Districts
                                          join k1 in db.Courts on k.District_Id equals k1.District_Id
                                          where k1.Court_Id == Courtid
                                          select k.District_Id).FirstOrDefault();

                        ViewData["district"] = new SelectList(db.Districts, "District_Id", "Description", DistrictId).ToList();

                        //Get Province using the District..........................................

                        int ProvinceId = (from a in db.Districts
                                          join b in db.Provinces on a.Province_Id equals b.Province_Id
                                          where a.District_Id.Equals(DistrictId)
                                          select b.Province_Id).FirstOrDefault();
                        ViewData["province"] = new SelectList(db.Provinces, "Province_Id", "Description", ProvinceId).ToList();
                    }

                    Session["presentdate"] = Presentenseid;

                    return(PartialView(VM));
                }
                else
                {
                    PCMPresentenceModel            Model1 = new PCMPresentenceModel();
                    PCMPresentenceDetailsViewModel VM1    = new PCMPresentenceDetailsViewModel();
                    //initialise view model

                    VM1.CommunityBasedOptions_List     = Model.GetCommunityBasedOption();
                    VM1.SupendedPostponedSentence_List = Model.GetSupendedPostponedSentence();
                    VM1.CaseStatus_List          = Model.GetCaseStatus();//..................?
                    VM1.RestorectiveJustice_List = Model.GetRestorectiveJustice();
                    VM1.ProgrammeType_List       = Model.GetProgrammeType();
                    VM1.Programme_List           = Model.GetProgramme();
                    VM1.Imprisoment_List         = Model.GetImprisoment();//..................?
                    VM1.Department_List          = Model.GetDepartment();
                    VM1.Court_List    = Model.GetAllCourt();
                    VM1.Province_List = Model.GetAllProvinces();
                    VM1.District_List = Model.GetAllDistrict();

                    //funtion that calls insert Socio Economy
                    Model1.InsertPresentence(VM1, intassid, userId);

                    PCMPresentenceDetailsViewModel VM2 = new PCMPresentenceDetailsViewModel();
                    int Presentenceidadd = Model.GetPCMPresentenseByassId(intassid);
                    VM2 = Model1.GetPresentenseList(Presentenceidadd);

                    VM2.CommunityBasedOptions_List     = Model.GetCommunityBasedOption();
                    VM2.SupendedPostponedSentence_List = Model.GetSupendedPostponedSentence();
                    VM2.CaseStatus_List          = Model.GetCaseStatus();//..................?
                    VM2.RestorectiveJustice_List = Model.GetRestorectiveJustice();
                    VM2.ProgrammeType_List       = Model.GetProgrammeType();
                    VM2.Programme_List           = Model.GetProgramme();
                    VM2.Imprisoment_List         = Model.GetImprisoment();//..................?
                    VM2.Department_List          = Model.GetDepartment();
                    VM2.Court_List        = Model.GetAllCourt();
                    VM2.Province_List     = Model.GetAllProvinces();
                    VM2.District_List     = Model.GetAllDistrict();
                    Session["presentadd"] = Presentenceidadd;
                    return(PartialView("GetPCMPresentense", VM2));
                }
            }
        }