Пример #1
0
 public ServiceResult AddCompanyMessage(int MemberID, int AddMemberID, AddCompanyMessageViewModel model)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         var company = DB_Service.Set<Company>().Include(x => x.CompanyMessage).Single(x => x.MemberID == MemberID);
         DB_Service.Attach<Company>(company);
         CompanyMessage cm = new CompanyMessage()
         {
             MemberID = AddMemberID,
             AddTime = DateTime.Now,
             Content = model.Content,
             Title = model.Name,
             Status = (int)CompanyMessageStatus.NotShow
         };
         company.CompanyMessage.Add(cm);
         DB_Service.Commit();
     }
     catch (Exception ex)
     {
         result.AddServiceError(Utilities.GetInnerMostException(ex));
     }
     return result;
 }
Пример #2
0
 public ActionResult AddMessage(int id, string name, string content)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         AddCompanyMessageViewModel model = new AddCompanyMessageViewModel()
         {
             Name = name,
             Content = content
         };
         var AddmemberID = Convert.ToInt32(CookieHelper.UID);
         result = companyService.AddCompanyMessage(id, AddmemberID, model);
     }
     catch (Exception ex)
     {
         result.AddServiceError(Utilities.GetInnerMostException(ex));
     }
     result.Message = "留言" + (result.Success ? "成功!" : "失败!");
     return Json(result);
 }
Пример #3
0
 public ActionResult Message(int id, AddCompanyMessageViewModel model)
 {
     ServiceResult result = new ServiceResult();
     if (ModelState.IsValid)
     {
         var memberID = Convert.ToInt32(CookieHelper.UID);
         result = companyService.AddCompanyMessage(id, memberID, model);
         result.Message = "留言" + (result.Success ? "成功!" : "失败!");
         TempData["Service_Result"] = result;
         if (result.Success)
         {
             return RedirectToAction("index");
         }
         else
         {
             return View(model);
         }
     }
     else
     {
         result.Message = "表单输入有误!";
         result.AddServiceError("表单输入有误!");
     }
     return View(model);
 }