示例#1
0
        public IActionResult Suppliers(int companyId)
        {
            ViewBag.CompanyId = companyId;

            AddSuppliersVM addSuppliersVM = new AddSuppliersVM();

            addSuppliersVM.CompanyId = companyId;
            return(View(addSuppliersVM));
        }
示例#2
0
        public IActionResult CreateSupplier(AddSuppliersVM addSuppliersVM)
        {
            if (!ModelState.IsValid)
            {
                ShowToaster("Please fill required fields", ToasterLevel.Danger);
                return(RedirectToAction("Suppliers", "Company", new { companyId = addSuppliersVM.CompanyId }));
            }
            var            config = new MapperConfiguration(cfg => cfg.CreateMap <AddSuppliersVM, AddSupplierDTO>());
            var            mapper = new Mapper(config);
            AddSupplierDTO dto    = mapper.DefaultContext.Mapper.Map <AddSupplierDTO>(addSuppliersVM);

            _userService.CreateAndUpdateSuppplier(dto);
            ShowToaster("Supplier created successfully", ToasterLevel.Success);

            return(RedirectToAction("Suppliers", "Company", new { companyId = dto.CompanyId }));
        }