public void Delete(CompanyNotice model) { var target = Find(model.ID); db.Remove <CompanyNotice>(target); db.Commit(); }
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 AddNotice(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, AddTime = DateTime.Now, Status = (int)CompanyNoticeStatus.ShowOnLine }; CompanyNoticeService.Create(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 Create(CompanyNotice model) { db.Add <CompanyNotice>(model); db.Commit(); }