Ejemplo n.º 1
0
 public ActionResult Banner(CompanyBannerViewModel model)
 {
     ViewBag.MenuItem = "shop-banner";
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     var member = MemberService.Find(CookieHelper.MemberID);
     if (member.Status < (int)MemberStatus.CompanyAuth)
     {
         return Redirect(Url.Action("openbiz", "reg"));
     }
     if (ModelState.IsValid)
     {
         try
         {
             var filepath = Server.MapPath("~" + model.BannerImg);
             FileHelper.deleteImg(filepath, 120);
             FileHelper.deleteImg(filepath, 430);
             FileHelper.deleteImg(filepath, 800);
             FileHelper.deleteImg(FileHelper.GetImgCutpath(filepath));
             model.BannerImg = FileHelper.GetImgCutpath(model.BannerImg, 960);
             CompanyService.SaveBanner(CookieHelper.MemberID, model);
             result.Message = "企业横幅保存成功!";
             return RedirectToAction("Banner");
         }
         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);
 }
Ejemplo n.º 2
0
 public Company SaveBanner(int MemberID, CompanyBannerViewModel model)
 {
     var company = Find(MemberID);
     db.Attach<Company>(company);
     company.BannerImg = model.BannerImg;
     db.Commit();
     return company;
 }