Ejemplo n.º 1
0
 public ServiceResult AddCompanyNotice(int MemberID, AddCompanyNoticeViewModel model)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var company = DB_Service.Set<Company>().Include(x => x.CompanyNotice).Single(x => x.MemberID == MemberID);
         DB_Service.Attach<Company>(company);
         CompanyNotice cn = new CompanyNotice()
         {
             MemberID = MemberID,
             AddTime = DateTime.Now,
             Content = model.Content,
             Title = model.Name,
             Status = (int)CompanyNoticeStatus.ShowOnLine
         };
         company.CompanyNotice.Add(cn);
         DB_Service.Commit();
     }
     catch (Exception ex)
     {
         result.AddServiceError(Utilities.GetInnerMostException(ex));
     }
     return result;
 }
Ejemplo n.º 2
0
 public ActionResult EditNotice(AddCompanyNoticeViewModel model)
 {
     ViewBag.MenuItem = "shop-notice";
     var member = memberService.Find(CookieHelper.MemberID);
     if (member.Status < (int)MemberStatus.CompanyAuth)
     {
         return Redirect(Url.Action("openbiz", "register"));
     }
     ServiceResult result = new ServiceResult();
     if (ModelState.IsValid)
     {
         result = companyService.EditCompanyNotice(CookieHelper.MemberID, model);
         result.Message = "编辑企业公告" + (result.Success ? "成功!" : "失败!");
         TempData["Service_Result"] = result;
         if (result.Success)
         {
             return RedirectToAction("Notice");
         }
         else
         {
             return View(model);
         }
     }
     else
     {
         result.Message = "表单输入有误!";
         result.AddServiceError("表单输入有误!");
     }
     return View(model);
 }
Ejemplo n.º 3
0
 public ServiceResult EditCompanyNotice(int MemberID, AddCompanyNoticeViewModel model)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var notice = GetCompanyNotice(model.ID);
         DB_Service.Attach<CompanyNotice>(notice);
         notice.Title = model.Name;
         notice.Content = model.Content;
         DB_Service.Commit();
     }
     catch (Exception ex)
     {
         result.AddServiceError(Utilities.GetInnerMostException(ex));
     }
     return result;
 }
Ejemplo n.º 4
0
 public ActionResult EditNotice(int id)
 {
     ViewBag.MenuItem = "shop-notice";
     var member = memberService.Find(CookieHelper.MemberID);
     if (member.Status < (int)MemberStatus.CompanyAuth)
     {
         return Redirect(Url.Action("openbiz", "register"));
     }
     var notice = companyService.GetCompanyNotice(id);
     if (notice == null)
     {
         return Content("<script>alert('非法操作!');window.history.go(-1);</script>");
     }
     var model = new AddCompanyNoticeViewModel()
     {
         ID = notice.ID,
         Name = notice.Title,
         Content = notice.Content
     };
     return View(model);
 }