public ServiceResult Update(Member_Favorite model) { ServiceResult result = new ServiceResult(); try { var target = Find(model.ID); DB_Service.Attach<Member_Favorite>(target); target.Status = model.Status; DB_Service.Commit(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ActionResult AddFavorite(int id) { ServiceResult result = new ServiceResult(); var MemberID = CookieHelper.MemberID; if (!member_FavoriteService.GetALL().Any(x => x.MemberID == MemberID && x.MediaID == id)) { try { Member_Favorite m_f = new Member_Favorite() { MediaID = id, MemberID = MemberID, AddTime = DateTime.Now }; member_FavoriteService.Create(m_f); } catch (Exception ex) { result.Message = "添加收藏出错!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); } } else { result.Message = "已经收藏了该媒体"; result.AddServiceError("已经收藏了该媒体"); } return Json(result, JsonRequestBehavior.AllowGet); }
public void Delete(Member_Favorite model) { var target = Find(model.ID); DB_Service.Remove<Member_Favorite>(target); DB_Service.Commit(); }
public void Create(Member_Favorite model) { DB_Service.Add<Member_Favorite>(model); DB_Service.Commit(); }