예제 #1
0
        public IActionResult InsertItem(SaleAdminViewModel saleAdminViewModel, bool?bDisabled)
        {
            if (ModelState.IsValid)
            {
                SaleAdmin saleAdmin = Mapper.Map <SaleAdmin>(saleAdminViewModel);

                _adminService.InsertSale(saleAdmin);
            }

            return(View("Index"));
        }
예제 #2
0
        public async Task InsertItemAsync([FromBody] SaleAdminViewModel saleAdminViewModel)
        {
            if (ModelState.IsValid)
            {
                SaleAdmin saleAdmin      = Mapper.Map <SaleAdmin>(saleAdminViewModel);
                var       searchShopName = Regex.Replace(saleAdmin.NameShop, @"\s+", "").ToLower();

                saleAdmin.FkShop = (await _adminService.GetShopByName(searchShopName))?.Id ?? (await _adminService.InsertShop(saleAdmin.NameShop, searchShopName));

                await _adminService.InsertSaleAsync(saleAdmin);
            }
        }