public void Update(CompanyNotice model) { var target = Find(model.ID); db.Attach<CompanyNotice>(target); target.Content = model.Content; target.Title = model.Title; db.Commit(); }
public ActionResult EditNotice(CompanyNoticeViewModel model) { ViewBag.MenuItem = "shop-notice"; var member = MemberService.Find(CookieHelper.MemberID); if (member.Status < (int)MemberStatus.CompanyAuth) { return Redirect(Url.Action("openbiz", "reg")); } ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { var entity = new CompanyNotice() { MemberID = CookieHelper.MemberID, Title = model.Name, Content = model.Content, ID = model.ID }; CompanyNoticeService.Update(entity); result.Message = "编辑企业公告成功!"; return RedirectToAction("Notice"); } catch (Exception ex) { result.Message = "编辑企业公告失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "编辑企业公告失败!", ex); return View(model); } } else { result.Message = "表单输入有误,请仔细填写表单!"; result.AddServiceError("表单输入有误,请仔细填写表单!"); } return View(model); }
public void Delete(CompanyNotice model) { var target = Find(model.ID); db.Remove<CompanyNotice>(target); db.Commit(); }
public void Create(CompanyNotice model) { db.Add<CompanyNotice>(model); db.Commit(); }