public ActionResult SaveAjax(RegionSubProgramModel regionsubprogram)
 {
     try
     {
         //call repository function to save the data in database
         regionsubprogramRepository.InsertOrUpdate(regionsubprogram.SubProgramID, Request.Form["SelectedRegion"].ToString(true));
         regionsubprogramRepository.Save();
         //set status message
         regionsubprogram.SuccessMessage = "Data has been savedcsuccessfully";
     }
     catch (CustomException ex)
     {
         regionsubprogram.ErrorMessage = ex.UserDefinedMessage;
     }
     catch (Exception ex)
     {
         ExceptionManager.Manage(ex);
         regionsubprogram.ErrorMessage = Constants.Messages.UnhandelledError;
     }
     //return the status message in json
     if (regionsubprogram.ErrorMessage.IsNotNullOrEmpty())
     {
         return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, regionsubprogram) }));
     }
     else
     {
         return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, regionsubprogram) }));
     }
 }
        public ActionResult EditorAjax(int subprogramID)
        {
            RegionSubProgramModel newRegionSubProgramModel = new RegionSubProgramModel();

            newRegionSubProgramModel.SubProgramID    = subprogramID;
            newRegionSubProgramModel.AllRegions      = regionRepository.All.ToList();
            newRegionSubProgramModel.AssignedRegions = regionsubprogramRepository.FindAllBySubProgramID(subprogramID).ToList();
            //return the html of editor to display on popup
            return(Content(this.RenderPartialViewToString(Constants.PartialViews.CreateOrEdit, newRegionSubProgramModel)));
        }
        public ActionResult Index()
        {
            if (!ViewBag.HasAccessToAdminModule)
            {
                WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action";
                return(RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty }));
            }
            RegionSubProgramModel newRegionSubProgramModel = new RegionSubProgramModel();

            newRegionSubProgramModel.AllRegions = regionRepository.All.ToList();
            return(View(newRegionSubProgramModel));
        }
Beispiel #4
0
        public List <RegionSubProgramModel> FindAllForList()
        {
            List <RegionSubProgramModel> data = new List <RegionSubProgramModel>();
            var roleList = context.RegionSubProgram.Join(context.SubProgram, left => left.SubProgramID, right => right.ID, (left, right) => new { left, right }).GroupBy(item => new { item.left.SubProgramID, SubProgramName = item.left.SubProgram.Name, item.right.ProgramID, ProgramName = item.right.Program.Name }).Select(item => item.Key).ToList();

            foreach (var role in roleList)
            {
                RegionSubProgramModel newRegionSubProgramModel = new RegionSubProgramModel()
                {
                    SubProgramName = role.SubProgramName,
                    ProgramName    = role.ProgramName
                };
                var regionsubprogramList = FindAllBySubProgramID(role.SubProgramID).ToList();
                if (regionsubprogramList != null)
                {
                    foreach (RegionSubProgram regionsubprogram in regionsubprogramList)
                    {
                        newRegionSubProgramModel.RegionNames = newRegionSubProgramModel.RegionNames.Concate(',', regionsubprogram.Region.Name);
                    }
                }
                data.Add(newRegionSubProgramModel);
            }
            return(data);
        }