public async Task <IHttpActionResult> UpdateShop([FromUri] int shopId, [FromBody] UpdateShopRequest updateSectionRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _shopService.UpdateShopAsync(shopId, updateSectionRequest); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent))); }
public async Task <IHttpActionResult> AddShop([FromBody] UpdateShopRequest createRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var shops = await _shopService.CreateShopAsync(createRequest); var location = string.Format("/api/shops/{0}", shops.Id); return(Created <Shop>(location, shops)); }
public async Task <int> UpdateShop(Guid shopId, UpdateShopRequest request) { var existShop = await _context.Shops.FirstOrDefaultAsync(shop => shop.shopId == shopId); if (existShop != null) { existShop.name = request.name; existShop.address = request.address; existShop.note = request.note; existShop.status = request.status; existShop.image = request.image; existShop.createUser = "******"; //TODO: Get UserName Login existShop.createDate = DateTime.Now; } return(await _context.SaveChangesAsync()); }
public async Task <IActionResult> UpdateShop(Guid shopId, [FromForm] ShopEditViewModel model) { if (ModelState.IsValid) { var request = new UpdateShopRequest { name = model.name, address = model.address, note = model.note, image = model.image, status = model.status }; var adminShopService = serviceLocator.GetService <IAdminShopService>(); await adminShopService.UpdateShop(shopId, request); TempData["message"] = $"{request.name} đã được cập nhật"; return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Nội Dung Nhập Không Phù Hợp"); return(View("Views/Shop/ShopEditView.cshtml", model)); } }