public JsonResult Update(BookCategory bookcate)
 {
     try
     {
         BookCategory bookcateold = _bookCategoryService.GetById(bookcate.CategoryID); bookcateold.CategoryName = bookcate.CategoryName; bookcateold.SeoTitle = bookcate.SeoTitle; bookcateold.MetaKeywords = bookcate.MetaKeywords; bookcateold.MetaDescription = bookcate.MetaDescription; bookcateold.ShowOnHome = bookcate.ShowOnHome;
         bookcate.Status = true;
         _bookCategoryService.Update(bookcateold);
         return(Json(new { success = true, message = "Sửa thành công" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.ToString() }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #2
0
        public async Task <bool> UpdateBookCategory(Guid id, UpdateBookCategoryDto model, string fields)
        {
            var bookCategory = await _service.Query(id, true);

            bookCategory.UpdateTime = DateTime.Now;
            return(await _service.Update(CommonClass.SetModelValue(model, bookCategory, fields)));
        }
 public IActionResult SaveEntity(BookCategoryViewModel bookCategoryVm)
 {
     if (!ModelState.IsValid)
     {
         IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
         return(new BadRequestObjectResult(allErrors));
     }
     else
     {
         if (bookCategoryVm.KeyId == 0)
         {
             _bookCategoryService.Add(bookCategoryVm);
         }
         else
         {
             _bookCategoryService.Update(bookCategoryVm);
         }
         _bookCategoryService.Save();
         return(new OkObjectResult(bookCategoryVm));
     }
 }
Exemple #4
0
 public async Task <ActionResult <ApiResponse> > Put(int id, [FromBody] BookCategoryDto entity)
 {
     return(new ApiResponse($"The record with {id} was updated.",
                            await bookCategoryService.Update(id, mapper.Map <BookCategory>(entity))));
 }
 public ActionResult <BookCategory> Update([FromBody] BookCategory categoey)
 {
     _bookCategoryService.Update(categoey);
     return(new ActionResult <BookCategory>(categoey));
 }