public IActionResult Edit(int id, SupplierFormModel supplierModel)
        {
            var supplierExists = suppliers.Exists(id);

            if (!supplierExists)
            {
                return(RedirectToAction(nameof(Local)));
            }

            if (!ModelState.IsValid)
            {
                return(View(supplierModel));
            }

            this.suppliers.Edit(id, supplierModel.Name, supplierModel.IsImporter);
            var userId = this.GetUserId();
            var date   = DateTime.Now;

            this.logs.Add(userId, "Edit", "Suppliers", date);

            TempData.AddSuccessMessage($"Supplier {supplierModel.Name} has been edited successfully");

            string suppType = supplierModel.IsImporter ? "Importers" : "Local";

            return(RedirectToAction(suppType));
        }
        public IActionResult Edit(int id, SupplierFormModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }
            var customerExists = this.suppliers.Exists(id);

            if (!customerExists)
            {
                return(this.NotFound());
            }

            this.suppliers
            .Edit(id, model.Name, model.IsImporter);

            this.logs.Create(this.User.Identity.Name, MethodBase.GetCurrentMethod().Name, ModelType);

            if (model.IsImporter)
            {
                return(this.RedirectToAction(nameof(this.Importers)));
            }

            return(this.RedirectToAction(nameof(this.Local)));
        }
Exemplo n.º 3
0
        public IActionResult Create(SupplierFormModel model)
        {
            this.suppliers.Create(
                model.Name,
                model.IsImporter);

            return(RedirectToAction(nameof(All)));
        }
        public IActionResult Create(SupplierFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            this.supplierService.Create(model.Name, model.IsImporter);

            return(RedirectToAction((nameof(All))));
        }
        public IActionResult Delete(int id, SupplierFormModel model)
        {
            if (!this.supplierService.Exists(id))
            {
                return(this.RedirectToAction(nameof(All)));
            }

            this.supplierService.Remove(id);

            return(this.RedirectToAction(model.IsImporter ? nameof(Importers) : nameof(Local)));
        }
        public IActionResult Create(SupplierFormModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(SupplierFormView, model));
            }

            this.supplierService.Create(model.Name, model.IsImporter);

            return(this.RedirectToAction(model.IsImporter ? nameof(Importers) : nameof(Local)));
        }
Exemplo n.º 7
0
        public IActionResult Edit(SupplierFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            this.suppliers.Edit((int)model.Id, model.Name, model.IsImporter);
            this.logs.Create(User.Identity.Name, SupplierTableName, Operation.Edit);

            return(RedirectToAction(nameof(All)));
        }
        public IActionResult Edit(int id, SupplierFormModel model)
        {
            if (!ModelState.IsValid)
            {
                model.IsEdit = true;

                return(View(model));
            }

            this.supplierService.Edit(id, model.Name, model.IsImporter);

            return(RedirectToAction(nameof(All)));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, SupplierFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await suppliers.EditSupplierAsync(id, model.Name);

            return(RedirectToAction(
                       nameof(SuppliersController.Index),
                       "Suppliers",
                       new { area = string.Empty }));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Add(SupplierFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await this.suppliers.AddAsync(model.Name, model.IsImporter);

            return(RedirectToAction(
                       nameof(SuppliersController.Index),
                       "Suppliers",
                       new { area = string.Empty }));
        }
        public IActionResult Edit(int id, SupplierFormModel model)
        {
            if (!this.supplierService.Exists(id))
            {
                return(this.RedirectToAction(nameof(All)));
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(SupplierFormView, model));
            }

            this.supplierService.Update(id, model.Name, model.IsImporter);

            return(this.RedirectToAction(model.IsImporter ? nameof(Importers) : nameof(Local)));
        }
Exemplo n.º 12
0
        public IActionResult Edit(int id)
        {
            var supplier = this.supplierService.GetById(id);

            if (supplier == null)
            {
                return(RedirectToAction(nameof(All)));
            }

            var model = new SupplierFormModel
            {
                Name       = supplier.Name,
                IsImporter = supplier.IsImporter
            };

            return(this.View(model));
        }
        public IActionResult Edit(int id)
        {
            SupplierDetailsServiceModel supplier = this.supplierService.GetSupplierById(id);

            if (supplier == null)
            {
                return(NotFound());
            }

            SupplierFormModel model = new SupplierFormModel
            {
                Name       = supplier.Name,
                IsImporter = supplier.IsImporter,
                IsEdit     = true
            };

            return(View(model));
        }
Exemplo n.º 14
0
        public IEnumerable <SupplierModel> CreateSupplier(SupplierFormModel data)
        {
            Supplier newSupplier = new Supplier();

            _context.Supplier.Add(newSupplier);
            _context.Entry(newSupplier).CurrentValues.SetValues(data);
            _context.SaveChanges();
            yield return(new SupplierModel
            {
                SupplierId = newSupplier.SupplierId,
                Name = newSupplier.Name,
                Address = newSupplier.Address,
                PLZ = newSupplier.PLZ,
                City = newSupplier.City,
                Email = newSupplier.Email,
                Contactperson = newSupplier.Contactperson,
                Phone = newSupplier.Phone
            });
        }
        public IActionResult Create(SupplierFormModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            this.suppliers
            .Create(model.Name, model.IsImporter);

            this.logs.Create(this.User.Identity.Name, MethodBase.GetCurrentMethod().Name, ModelType);

            if (model.IsImporter)
            {
                return(this.RedirectToAction(nameof(this.Importers)));
            }

            return(this.RedirectToAction(nameof(this.Local)));
        }
        public IActionResult Create(SupplierFormModel supplierModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(supplierModel));
            }

            this.suppliers.Create(supplierModel.Name, supplierModel.IsImporter);

            var userId = this.GetUserId();
            var date   = DateTime.Now;

            this.logs.Add(userId, "Add", "Suppliers", date);

            string suppType = supplierModel.IsImporter ? "Importers" : "Local";

            TempData.AddSuccessMessage($"Supplier {supplierModel.Name} has been created successfully");

            return(RedirectToAction(suppType));
        }
Exemplo n.º 17
0
 public IEnumerable <SupplierModel> CreateSupplier(SupplierFormModel data)
 {
     return(this._context.CreateSupplier(data));
 }