public void Update(Member_Scheme model)
 {
     var target = Find(model.ID);
     DB_Service.Attach<Member_Scheme>(target);
     target.Name = model.Name;
     target.Description = model.Description;
     target.LastTime = DateTime.Now;
     target.Status = model.Status;
     DB_Service.Commit();
 }
 public void Create(Member_Scheme model)
 {
     DB_Service.Add<Member_Scheme>(model);
     DB_Service.Commit();
 }
 public void Delete(Member_Scheme model)
 {
     var target = Find(model.ID);
     DB_Service.Remove<Member_Scheme>(target);
     DB_Service.Commit();
 }
 public ActionResult AddScheme(AddSchemeViewModel model)
 {
     ServiceResult result = new ServiceResult();
     try
     {
         Scheme_Media sm = new Scheme_Media();
         sm.MediaID = model.id;
         sm.StartTime = Convert.ToDateTime(model.startTime);
         sm.EndTime = Convert.ToDateTime(model.endTime);
         sm.Price = Convert.ToDecimal(model.price);
         sm.PeriodCode = model.periodCode;
         sm.PeriodCount = model.periodCount;
         if (string.IsNullOrEmpty(model.schemeName) && model.schemeId != 0)
         {
             sm.SchemeID = model.schemeId;
             if (scheme_MediaService.GetALL().Where(x => x.MediaID == model.id && x.SchemeID == model.schemeId).Any())
             {
                 result.AddServiceError("该方案已经包含了此媒体");
                 result.Message = "该方案已经包含了此媒体!";
             }
         }
         else
         {
             Member_Scheme ms = new Member_Scheme()
             {
                 AddTime = DateTime.Now,
                 Name = model.schemeName,
                 Description = model.schemeDescription,
                 LastTime = DateTime.Now,
                 MemberID = CookieHelper.MemberID
             };
             member_SchemeService.Create(ms);
             sm.SchemeID = ms.ID;
         }
         if (result.Success)
         {
             scheme_MediaService.Create(sm);
             result.Message = "加入方案成功!";
         }
     }
     catch (Exception ex)
     {
         result.Message = "加入方案失败!";
         result.AddServiceError(Utilities.GetInnerMostException(ex));
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }