public ReturnValue<bool> DeleteAlbum(T_Album iAlbum) { try { _dataContext.T_Album.Remove(iAlbum); _dataContext.SaveChanges(); return new ReturnValue<bool>(true, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public ReturnValue<bool> AddNewAlbum(T_Album iAlbum) { if (IsExist(iAlbum)) return new ReturnValue<bool>(false, "Mục đã tồn tại"); try { iAlbum.Slug = TNVTH.Web.Utilities.Common.ToUrlSlug(iAlbum.Title); _dataContext.T_Album.Add(iAlbum); _dataContext.SaveChanges(); return new ReturnValue<bool>(true, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public ActionResult AddNew(T_Album iAlbum) { ReturnValue<bool> result = new ReturnValue<bool>(false, ""); if (ModelState.IsValid) { result = _service.AddNewAlbum(iAlbum); } if (result.RetValue) { return RedirectToAction("List", "Album"); } else { // Get Album_List again ModelState.AddModelError("Error", result.Msg); return View(iAlbum); } }
public ActionResult Edit(T_Album iAlbum) { ReturnValue<bool> result = _service.UpdateAlbum(iAlbum); if (result.RetValue) { return RedirectToAction("List", "Album"); } else { // Get Album_List again ModelState.AddModelError("Error", result.Msg); return View(iAlbum); } }
public T_Album AddNewAlbumAndReturn(T_Album iAlbum) { _dataContext.T_Album.Add(iAlbum); _dataContext.SaveChanges(); return iAlbum; }
public ReturnValue<bool> UpdateAlbum(T_Album iAlbum) { //if (IsExist(iAlbum)) return new ReturnValue<bool>(false, "Mục đã tồn tại"); try { _dataContext.Entry(iAlbum).State = EntityState.Modified; return new ReturnValue<bool>(_dataContext.SaveChanges() > 0, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public bool IsExist(T_Album iAlbum) { return false; }