Exemplo n.º 1
0
        public ActionResult Edit(string id)
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller)
            {
                return(RedirectToAction("Detail", new { id }));
            }

            var nppbkc = service.Find(id);

            if (nppbkc == null)
            {
                HttpNotFound();
            }
            if (nppbkc.IS_DELETED == true)
            {
                return(RedirectToAction("Detail", "NPPBKC", new { id = nppbkc.NPPBKC_ID }));
            }
            var model  = new NewNPPBKCViewModel.NppbkcModel();
            var detail = this.MapToModel(nppbkc);

            model.Detail      = detail;
            model.MainMenu    = _mainMenu;
            model.CurrentMenu = PageInfo;
            model.Plant       = _plantBll.Get(id);
            var changeHistoryList = _changesHistoryBll.GetByFormTypeAndFormId(Enums.MenuList.NPPBKC, id);

            model.ChangesHistoryList = Mapper.Map <List <ChangesHistoryItemModel> >(changeHistoryList);
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Create(NewNPPBKCViewModel.NppbkcModel model)
        {
            try
            {
                var origin = this.MapToModel(new CustomService.Data.MASTER_NPPBKC());
                model.Detail.CreateDate   = origin.CreateDate;
                model.Detail.CreatedBy    = origin.CreatedBy;
                model.Detail.ModifiedDate = origin.ModifiedDate;
                model.Detail.ModifiedBy   = origin.ModifiedBy;
                model.Detail.Is_Deleted   = origin.Is_Deleted;
                var nppbkc = this.MapToEntity(model.Detail);
                var logs   = SetChanges(origin, nppbkc);
                service.Save(nppbkc, CurrentUser.USER_ID, logs);


                AddMessageInfo(Constans.SubmitMessage.Saved, Enums.MessageInfoType.Success
                               );
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                AddMessageInfo(ex.Message, Enums.MessageInfoType.Error
                               );
                model.MainMenu    = _mainMenu;
                model.CurrentMenu = PageInfo;
                return(View("Create", model));
            }
        }
Exemplo n.º 3
0
        public ActionResult Create()
        {
            try
            {
                if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller)
                {
                    AddMessageInfo("You don't have permission to access", Enums.MessageInfoType.Error
                                   );
                    return(RedirectToAction("Index"));
                }

                var model = new NewNPPBKCViewModel.NppbkcModel();;
                model.Detail           = new NewNPPBKCViewModel.NewNppbckDetails();
                model.Detail.StartDate = DateTime.Now;
                model.Detail.EndDate   = DateTime.Now.AddYears(1);
                model.MainMenu         = _mainMenu;
                model.CurrentMenu      = PageInfo;

                return(View(model));
            }
            catch (Exception ex)
            {
                AddMessageInfo(ex.Message, Enums.MessageInfoType.Error
                               );
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(NewNPPBKCViewModel.NppbkcModel model)
        {
            //if (!ModelState.IsValid)
            //{
            //    var Nppbkc = _nppbkcBll.GetById(model.Detail.VirtualNppbckId);
            //    model.MainMenu = Enums.MenuList.MasterData;
            //    model.CurrentMenu = PageInfo;

            //    var detail = AutoMapper.Mapper.Map<VirtualNppbckDetails>(Nppbkc);

            //    model.Detail = detail;
            //    return View("Edit", model);
            //}

            try
            {
                var nppbkcId = model.Detail.VirtualNppbckId;
                var nppbkc   = service.Find(nppbkcId);
                var origin   = this.MapToModel(nppbkc);
                model.Detail.CreateDate   = origin.CreateDate;
                model.Detail.CreatedBy    = origin.CreatedBy;
                model.Detail.ModifiedDate = origin.ModifiedDate;
                model.Detail.ModifiedBy   = origin.ModifiedBy;
                model.Detail.Is_Deleted   = origin.Is_Deleted;
                nppbkc = this.MapToEntity(model.Detail);
                var logs = SetChanges(origin, nppbkc);
                //AutoMapper.Mapper.Map(model.Detail, nppbkc);
                service.Save(nppbkc, CurrentUser.USER_ID, logs);


                AddMessageInfo(Constans.SubmitMessage.Updated, Enums.MessageInfoType.Success
                               );
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                AddMessageInfo(ex.Message, Enums.MessageInfoType.Error
                               );
                model.MainMenu    = _mainMenu;
                model.CurrentMenu = PageInfo;
                return(View("Edit", model));
            }
        }
Exemplo n.º 5
0
        public ActionResult Detail(string id)
        {
            var nppbkc = service.Find(id);

            if (nppbkc == null)
            {
                HttpNotFound();
            }
            var changeHistoryList = _changesHistoryBll.GetByFormTypeAndFormId(Enums.MenuList.NPPBKC, id);

            var model = new NewNPPBKCViewModel.NppbkcModel();

            model.MainMenu    = _mainMenu;
            model.CurrentMenu = PageInfo;
            model.Plant       = _plantBll.Get(id);
            var detail = this.MapToModel(nppbkc);

            model.Detail             = detail;
            model.ChangesHistoryList = Mapper.Map <List <ChangesHistoryItemModel> >(changeHistoryList);

            return(View(model));
        }