Beispiel #1
0
        private ActionResult Edit(SRStatusViewModel model)
        {
            try
            {
                ViewBag.EditMode = "Edit";
                initList(1);

                //Initialize mutiselectlist
                List <SrPageItemEntity> pageCurr = null;
                List <SrPageItemEntity> pageAll  = null;

                if (!isSaveMode)
                {
                    using (SrPageFacade pageFacade = new SrPageFacade())
                    {
                        pageCurr = pageFacade.GetSrPages(null, model.SRStatusId).ToList();
                        pageAll  = pageFacade.GetSrPages()
                                   .OrderBy(x => x.SrPageName)
                                   .ToList();
                    }

                    model.SRPageIdList = pageCurr.Select(x => x.SrPageId ?? 0).ToList();
                    model.SRPageIdAll  = pageAll.OrderBy(x => x.SrPageName)
                                         .Select(x => x.SrPageId ?? 0).ToList();

                    model.Old_SRPageIdList = model.SRPageIdList;
                }
                else
                {
                    using (SrPageFacade pageFacade = new SrPageFacade())
                    {
                        pageAll = pageFacade.GetSrPages()
                                  .OrderBy(x => x.SrPageName)
                                  .ToList();
                    }
                }

                if (model.SRPageIdList != null)
                {
                    model.SRPageListAll = new MultiSelectList(pageAll.Where(x => !model.SRPageIdList.Contains(x.SrPageId ?? 0)).ToDictionary(x => x.SrPageId.ConvertToString(), x => x.SrPageName), "Key", "Value");
                    pageCurr            = pageAll.Where(x => model.SRPageIdList.Contains(x.SrPageId ?? 0)).ToList();
                    model.SRPageList    = new MultiSelectList(pageCurr.ToDictionary(x => x.SrPageId.ConvertToString(), x => x.SrPageName), "Key", "Value");
                }
                else
                {
                    model.SRPageListAll = new MultiSelectList(pageAll.ToDictionary(x => x.SrPageId.ConvertToString(), x => x.SrPageName), "Key", "Value");
                    model.SRPageList    = new MultiSelectList(new List <int>());
                }
                return(View("~/Views/Status/Create.cshtml", model));
            }
            catch (Exception ex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Edit Catch- SR Status").Add("Error Message", ex.ToString()).ToFailLogString());
                ViewBag.ErrorMessage = ex.ToString();
                return(View("~/Views/Status/Create.cshtml", model));
            }
        }
Beispiel #2
0
        private void initList(byte type = 0)
        {
            using (SrStatusFacade statfacade = new SrStatusFacade())
            {
                ViewBag.SRStateList = statfacade.GetSrState()
                                      .OrderBy(x => x.SRStateId)
                                      .Select(x => new SelectListItem()
                {
                    Value = x.SRStateId.ToString(),
                    Text  = x.SRStateName
                });
                using (SrPageFacade pageFacade = new SrPageFacade())
                {
                    ViewBag.SRPageList = pageFacade.GetSrPages()
                                         .OrderBy(x => x.SrPageName)
                                         .Select(x => new SelectListItem()
                    {
                        Value = x.SrPageId.ToString(),
                        Text  = x.SrPageName
                    });
                }
                switch (type)
                {
                case 1:
                {
                    //Create Page
                }
                break;

                default:
                {
                    //Search Page
                    ViewBag.SRStatusList = statfacade.GetSrStatus()
                                           .OrderBy(x => x.SRStatusName)
                                           .Select(x => new SelectListItem()
                        {
                            Value = x.SRStatusId.ToString(),
                            Text  = x.SRStatusName
                        });
                }
                break;
                }
            }
        }
Beispiel #3
0
        public ActionResult Create(SRStatusViewModel model)
        {
            try
            {
                initList(1);
                List <SrPageItemEntity> pageCurr = null;
                List <SrPageItemEntity> pageAll  = null;

                if (!isSaveMode)
                {
                    model = new SRStatusViewModel()
                    {
                        SRState  = new SRStateEntity(),
                        SendHP   = false,
                        SendRule = false,
                        Status   = "A"
                    };

                    model.CreateUser = UserInfo;
                    model.UpdateUser = UserInfo;
                    ModelState.Clear();
                }

                using (SrPageFacade pageFacade = new SrPageFacade())
                {
                    pageAll = pageFacade.GetSrPages()
                              .OrderBy(x => x.SrPageName)
                              .ToList();
                }

                model.SRPageIdAll = pageAll.OrderBy(x => x.SrPageName)
                                    .Select(x => x.SrPageId ?? 0).ToList();

                if (model.SRPageIdList != null)
                {
                    pageCurr         = pageAll.Where(x => model.SRPageIdList.Contains(x.SrPageId ?? 0)).ToList();
                    model.SRPageList = new MultiSelectList(pageCurr.ToDictionary(x => x.SrPageId.ConvertToString(), x => x.SrPageName), "Key", "Value");
                }
                else
                {
                    model.SRPageList = new MultiSelectList(new List <int>()
                    {
                    });
                }

                model.SRPageListAll = new MultiSelectList(pageAll
                                                          .OrderBy(x => x.SrPageName)
                                                          .ToDictionary(x => x.SrPageId.ConvertToString(), x => x.SrPageName), "Key", "Value");

                model.Old_SRPageIdList = new List <int>()
                {
                };

                ViewBag.EditMode = "Create";
                return(View("~/Views/Status/Create.cshtml", model));
            }
            catch (Exception ex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Edit Catch- SR Status").Add("Error Message", ex.ToString()).ToFailLogString());
                ViewBag.ErrorMessage = ex.ToString();
                return(View("~/Views/Status/Create.cshtml", model));
            }
        }