コード例 #1
0
 public IActionResult Edit(SupplierEditViewModel supplier)
 {
     if (!this.ModelState.IsValid)
     {
         return(this.View(supplier));
     }
     this.suppliers.Edit(supplier);
     return(this.Redirect("/Suppliers/All"));
 }
コード例 #2
0
        public void Edit(SupplierEditViewModel supplier)
        {
            var Supplier = this.db.Suppliers.FirstOrDefault(x => x.Id == supplier.Id);

            this.db.Entry(Supplier).State = EntityState.Detached;
            Supplier = this.mapper.Map <SupplierEditViewModel, Supplier>(supplier);
            this.db.Update(Supplier);
            this.db.SaveChanges();
        }
コード例 #3
0
        public async Task <IActionResult> EditSupplier(long id)
        {
            SupplierEditViewModel model = new SupplierEditViewModel()
            {
                Supplier = await _repository.GetSupplierByIdAsync(id)
            };

            if (model != null)
            {
                ViewBag.Title = _stringLocalizer["Edit Supplier"].ToString();
                return(View(model));
            }
            TempData["SupplierMessage"] = _stringLocalizer["Selected Supplier was missing"].ToString();
            return(RedirectToAction(nameof(Index)));
        }
コード例 #4
0
        public async Task <IActionResult> DetailSupplier(long id)
        {
            Supplier sup = await _repository.GetSupplierByIdAsync(id);

            if (sup != null)
            {
                SupplierEditViewModel model = new SupplierEditViewModel()
                {
                    Supplier = sup
                };
                ViewBag.Title = _stringLocalizer["Detailes Supplier"].ToString();
                return(View(model));
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(SupplierEditViewModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.RedirectToAction("Edit", new { id = inputModel.Id }));
            }

            var supplierId = await this
                             .suppliersService
                             .EditAsync(inputModel.Name, inputModel.Country, inputModel.Address, inputModel.NewImage, inputModel.Id);

            if (supplierId == null)
            {
                return(this.RedirectToAction("Error", "Home"));
            }

            this.TempData[Notifications.Key] = Notifications.SuccessfullyEditedSupplier;

            return(this.RedirectToAction("Details", new { id = supplierId }));
        }
コード例 #6
0
        // GET
        //Supplier/Edit
        public IActionResult Edit()
        {
            //ViewData["Message"] = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            //ViewData["id"] = 123;
            var viewModel = new SupplierEditViewModel();

            viewModel.Id      = 123;
            viewModel.Message = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

            viewModel.Colors.Add("Green");
            viewModel.Colors.Add("Red");
            viewModel.Colors.Add("Blue");
            viewModel.Colors.Add("Yellow");

            //int i = 12;
            //if (i == 12) return 1;
            //else return 123;
            //return ((i == 12) ? "2311" : "123");


            return(View(viewModel));
        }
コード例 #7
0
        public async Task <IActionResult> EditSupplier(SupplierEditViewModel model)
        {
            int result = 0;

            if (ModelState.IsValid)
            {
                model.Supplier.LastModifiedByName = User.Identity.Name;
                result = await _repository.UpdateSupplierAsync(model.Supplier);

                if (result < 1)
                {
                    TempData["SupplierMessage"] = _stringLocalizer["Nothing changed"].ToString();
                    return(RedirectToAction(nameof(Index)));
                }
                TempData["SupplierMessage"] = _stringLocalizer["Supplier modified successfully"].ToString();
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                model.Supplier.Contacts = (await _repository.GetSupplierByIdAsync(model.Supplier.Id)).Contacts;
                ViewBag.Title           = _stringLocalizer["Edit Supplier"].ToString();
                return(View(model));
            }
        }