Example #1
0
 public void Update(Scheme_Media model)
 {
     var target = Find(model.ID);
     DB_Service.Attach<Scheme_Media>(target);
     target.PeriodCode = model.PeriodCode;
     target.Price = model.Price;
     target.StartTime = model.StartTime;
     target.EndTime = model.EndTime;
     DB_Service.Commit();
 }
Example #2
0
        public ActionResult EditSchemeMedia(AjaxEditSchemeViewModel model)
        {
            ServiceResult result = new ServiceResult();
            try
            {
                var startTime = Convert.ToDateTime(model.startTime);

                var schemeMedia = new Scheme_Media()
                {
                    ID = model.id,
                    PeriodCode = model.periodCode,
                    PeriodCount = model.periodCount,
                    StartTime = startTime,
                    Price = Convert.ToDecimal(model.price),
                    EndTime = startTime.AddDays(model.periodCode * model.periodCount)
                };

                scheme_MediaService.Update(schemeMedia);
            }
            catch (Exception ex)
            {
                result.Message = "加入方案失败!";
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Example #3
0
 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);
 }
Example #4
0
 public void Delete(Scheme_Media model)
 {
     var target = Find(model.ID);
     DB_Service.Remove<Scheme_Media>(target);
     DB_Service.Commit();
 }
Example #5
0
 public void Create(Scheme_Media model)
 {
     DB_Service.Add<Scheme_Media>(model);
     DB_Service.Commit();
 }