コード例 #1
0
        public virtual IActionResult Create(ProcuringAgencyModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProcuringAgency))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var item = model.ToEntity <ProcuringAgency>();

                //ensure we have "/" at the end
                _procuringAgencyService.InsertProcuringAgency(item);

                //activity log
                _customerActivityService.InsertActivity("AddNewProcuringAgency",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewProcuringAgency"), item.Id), item);

                SuccessNotification(_localizationService.GetResource("AppWork.Contracts.ProcuringAgency.Added"));

                return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _procuringAgencyModelFactory.PrepareProcuringAgencyModel(model, null);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #2
0
        public virtual IActionResult _Create(ProcuringAgencyModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var item = model.ToEntity <ProcuringAgency>();

                //ensure we have "/" at the end
                _procuringAgencyService.InsertProcuringAgency(item);
                //activity log
                _customerActivityService.InsertActivity("AddNewProcuringAgency",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewProcuringAgency"), item.Id), item);

                return(JsonSuccessMessage("ok", item));
            }
            //if we got this far, something failed, redisplay form
            return(JsonErrorMessage());
        }
コード例 #3
0
        public ProcuringAgencyModel PrepareProcuringAgencyModel(ProcuringAgencyModel model, ProcuringAgency item, bool excludeProperties = false)
        {
            if (item != null)
            {
                //fill in model values from the entity
                model          = model ?? item.ToModel <ProcuringAgencyModel>();
                model.TypeText = _localizationService.GetLocalizedEnum(item.procuringAgencyType);
            }
            //neu thong tin chu dau tu dang sua la PECC1 thi chi cho phep sua thong tin khac, thong tin loai chu dau tu khong cho sua
            if (model.procuringAgencyType == ProcuringAgencyType.PECC1)
            {
                model.lsType = ((ProcuringAgencyType)model.TypeId).ToSelectList(true, new int[] { 0, (int)ProcuringAgencyType.Main, (int)ProcuringAgencyType.JointVenture });
            }
            else
            {
                model.lsType = ((ProcuringAgencyType)model.TypeId).ToSelectList(true, new int[] { 0, (int)ProcuringAgencyType.PECC1 });
            }

            return(model);
        }
コード例 #4
0
        public virtual IActionResult Edit(ProcuringAgencyModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProcuringAgency))
            {
                return(AccessDeniedView());
            }

            //try to get a store with the specified id
            var item = _procuringAgencyService.GetProcuringAgencyById(model.Id);

            if (item == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                item = model.ToEntity(item);


                _procuringAgencyService.UpdateProcuringAgency(item);

                //activity log
                _customerActivityService.InsertActivity("EditProcuringAgency",
                                                        string.Format(_localizationService.GetResource("ActivityLog.EditProcuringAgency"), item.Id), item);



                SuccessNotification(_localizationService.GetResource("AppWork.Contracts.ProcuringAgency.Updated"));

                return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _procuringAgencyModelFactory.PrepareProcuringAgencyModel(model, item, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }