public bool EditCategory(CategoryMv category) { var data = new DanhMuc(); data.TenDanhMuc = category.Name; data.MaDanhMuc = category.ID; return(cl.SuaDanhMuc(data)); }
public CategoryMv getCategoryDetail(int id) { var result = new CategoryMv(); var data = cl.ChitTietDanhMuc(id); result.Name = data.TenDanhMuc; return(result); }
public bool CreateNewCategory(CategoryMv category) { var data = new DanhMuc(); data.TenDanhMuc = category.Name; var result = cl.ThemMoiDanhMuc(data); return(result); }
public IActionResult Post([FromBody] CategoryMv category) { try { return(Created(Url.Action("Get"), _container.CategoryFactory.CreateNew(category))); } catch (Exception e) { Console.WriteLine(e); return(BadRequest()); } }
public IActionResult Put(Guid id, [FromBody] CategoryMv category) { try { if (_container.CategoryFactory.Update(id, category)) { return(Ok()); } return(BadRequest()); } catch (Exception e) { Console.WriteLine(e); return(BadRequest()); } }
public IActionResult Create(CategoryMv category) { if (!ModelState.IsValid) { return(View()); } category.CategoryParent = TypeCategories.Parent; var res = ServiceApi.PostData <CategoryMv>(ModelName, category).Result; if (res.IsSuccessStatusCode) { TempData[ConstKey.Success] = "Success"; return(RedirectToAction("Index")); } TempData[ConstKey.Error] = "Error,Try Again! "; return(View()); }
public IActionResult Post([FromBody] CategoryMv category) { try { var res = _unitOfWork.Categories.CreateNewAddReturnObject(_mapper.Map <Category>(category)); if (_unitOfWork.Commit()) { return(Created(Url.Action("Get"), res)); } return(BadRequest()); } catch (Exception e) { Console.WriteLine(e.Message); return(NotFound("No data")); } }
public IActionResult Put(Guid id, [FromBody] CategoryMv categoryMv) { try { var category = _unitOfWork.Categories.GetById(id).Result; category.Name = categoryMv.Name; _unitOfWork.Categories.Edit(category); if (_unitOfWork.Commit()) { return(Ok()); } return(BadRequest()); } catch (Exception e) { Console.WriteLine(e.Message); return(NotFound("No data")); } }
public IActionResult Update(CategoryMv category) { if (!ModelState.IsValid) { return(RedirectToAction("DetailParent", "Category", new { id = category.Id })); } ; category.CategoryParent = TypeCategories.Child; var res = ServiceApi.Update <CategoryMv>(ModelName, category.Id, category).Result; if (res.IsSuccessStatusCode) { TempData[ConstKey.Success] = "Success"; } else { TempData[ConstKey.Error] = "Error,Try Again! "; } return(RedirectToAction("DetailParent", "Category", new { id = category.Id })); }
public ActionResult Edit(CategoryMv category) { if (ModelState.IsValid) { try { if (!new CategoryDao().checkExistCategory(category.Name)) { if (new CategoryDao().EditCategory(category)) { TempData["SuccessMes"] = "Sửa danh mục thành công"; return(RedirectToAction("Index")); } else { ViewBag.Message = "Hệ thống gặp sự cố không thể thêm được thử lại"; return(View()); } } else { ViewBag.Message = "Danh Mục này đã có sẵn từ trước vui lòng kiểm tra lại"; return(View()); } } catch { ViewBag.Message = "Hệ thống gặp sự cố, hãy thử lại lần nữa"; return(View()); } } else { return(View()); } }