Exemplo n.º 1
0
        public async Task <IActionResult> EditVendor(Areas.Administration.Models.VendorModel model)
        {
            var vendor = await _vendorManagementService.GetVendor((int)model.VendorId);

            if (vendor == null)
            {
                return(RedirectToAction("SetupEdit"));
            }

            if (ModelState.IsValid)
            {
                var result = await _vendorManagementService.UpdateVendor(vendor, model);

                if (result != null)
                {
                    SuccessNotification("The vendor data has been updated successfully.");
                    return(RedirectToAction("EditVendor", "VendorManagement",
                                            new { AutoID = model.VendorId }));
                }
                else
                {
                    ModelState.AddModelError("", "Something went wrong while editing vendor record");
                }
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> VendorAdd(Areas.Administration.Models.VendorModel model)
        {
            if (ModelState.IsValid)
            {
                var vendorObj = _mapper.Map <Vendor>(model);
                vendorObj.ClientId = (int)_workContext.CurrentCustomer.ClientId;

                var result = await _vendorManagementService.InsertVendor(vendorObj);

                if (result)
                {
                    SuccessNotification("The vendor data has been saved successfully.");
                    return(RedirectToAction("VendorAdd"));
                }
                else
                {
                    ModelState.AddModelError("", "Something went wrong while saving vendor record");
                }
            }
            return(View(model));
        }