public async Task <int> AddShop(AddShopRequest request) { var shop = new POSSolution.Application.Models.Shop() { name = request.name, address = request.address, image = request.image, note = request.note, status = request.status, createUser = "******", //TODO: Get UserName Login createDate = DateTime.Now, updateDate = DateTime.Now }; _context.Shops.Add(shop); return(await _context.SaveChangesAsync()); }
public async Task <IActionResult> InsertShop([FromForm] ShopDetailViewModel model) { if (ModelState.IsValid) { var request = new AddShopRequest { name = model.name, address = model.address, note = model.note, status = model.status, image = model.image }; var adminShopService = serviceLocator.GetService <IAdminShopService>(); await adminShopService.AddShop(request); TempData["message"] = $"{request.name} đã được thêm"; return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Nội Dung Nhập Không Phù Hợp"); return(View("Views/Shop/ShopDetailView.cshtml", model)); } }