public void UpdateServiceSetting(LimitTimeBuySettingModel model) { MarketSettingInfo price = context.MarketSettingInfo.FirstOrDefault((MarketSettingInfo m) => (int)m.TypeId == 1); if (price == null || price.Id == 0) { MarketSettingInfo marketSettingInfo = new MarketSettingInfo() { Price = model.Price, TypeId = MarketType.LimitTimeBuy }; context.MarketSettingInfo.Add(marketSettingInfo); } else { price.Price = model.Price; //if (price.Himall_MarketSettingMeta.Count() != 0) //{ // MarketSettingMetaInfo str = price.Himall_MarketSettingMeta.FirstOrDefault((MarketSettingMetaInfo m) => // { // if (m.MarketId != price.Id) // { // return false; // } // return m.MetaKey.ToLower().Equals("revicedays"); // }); // str.MetaValue = model.ReviceDays.ToString(); //} } context.SaveChanges(); }
/// <summary> /// 获取限时购服务设置 /// </summary> /// <returns></returns> public LimitTimeBuySettingModel GetServiceSetting() { int days = 0; var result = DbFactory.Default.Get <MarketSettingInfo>().Where(m => m.TypeId == MarketType.LimitTimeBuy).FirstOrDefault(); if (result == null || result.Id == 0) { return(null); } var model = new LimitTimeBuySettingModel() { Price = result.Price, ReviceDays = 0 }; var setting = DbFactory.Default.Get <MarketSettingMetaInfo>(p => p.MarketId == result.Id).ToList(); if (setting.Count != 0) { var marketMeta = setting.FirstOrDefault(m => m.MetaKey.ToLower() == "revicedays"); if (marketMeta != null) { var ReviceDays = marketMeta.MetaValue; if (int.TryParse(ReviceDays, out days)) { } } model.ReviceDays = days; } return(model); }
public LimitTimeBuySettingModel GetServiceSetting() { int num = 0; MarketSettingInfo marketSettingInfo = ( from m in context.MarketSettingInfo where (int)m.TypeId == 1 select m).FirstOrDefault(); if (marketSettingInfo == null || marketSettingInfo.Id == 0) { return(null); } LimitTimeBuySettingModel limitTimeBuySettingModel = new LimitTimeBuySettingModel() { Price = marketSettingInfo.Price, ReviceDays = 0 }; LimitTimeBuySettingModel limitTimeBuySettingModel1 = limitTimeBuySettingModel; if (marketSettingInfo.Himall_MarketSettingMeta.Count() != 0) { MarketSettingMetaInfo marketSettingMetaInfo = marketSettingInfo.Himall_MarketSettingMeta.FirstOrDefault((MarketSettingMetaInfo m) => m.MetaKey.ToLower().Equals("revicedays")); if (marketSettingMetaInfo != null) { int.TryParse(marketSettingMetaInfo.MetaValue, out num); } limitTimeBuySettingModel1.ReviceDays = num; } return(limitTimeBuySettingModel1); }
public JsonResult SaveServiceSetting(decimal Price, int ReviceDays = 0) { Result result = new Result(); try { LimitTimeBuySettingModel limitTimeBuySettingModel = new LimitTimeBuySettingModel() { Price = Price, ReviceDays = ReviceDays }; ServiceHelper.Create <ILimitTimeBuyService>().UpdateServiceSetting(limitTimeBuySettingModel); result.success = true; result.msg = "保存成功!"; } catch (HimallException himallException) { result.msg = himallException.Message; } catch (Exception exception) { Log.Error("保存出错", exception); result.msg = "保存出错!"; } return(Json(result)); }
/// <summary> /// 更新限时购服务设置 /// </summary> public void UpdateServiceSetting(LimitTimeBuySettingModel model) { var market = DbFactory.Default.Get <MarketSettingInfo>().Where(m => m.TypeId == MarketType.LimitTimeBuy).FirstOrDefault(); if (market != null && market.Id != 0) { market.Price = model.Price; DbFactory.Default.Update(market); } else { MarketSettingInfo info = new MarketSettingInfo() { Price = model.Price, TypeId = MarketType.LimitTimeBuy }; DbFactory.Default.Add(info); } }
public JsonResult SaveServiceSetting(decimal Price, int ReviceDays = 0) { Result result = new Result(); try { var model = new LimitTimeBuySettingModel { Price = Price, ReviceDays = ReviceDays }; _iLimitTimeBuyService.UpdateServiceSetting(model); result.success = true; result.msg = "保存成功!"; } catch (HimallException ex) { result.msg = ex.Message; } catch (Exception ex) { Log.Error("保存出错", ex); result.msg = "保存出错!"; } return(Json(result)); }
public ActionResult ServiceSetting() { LimitTimeBuySettingModel model = _iLimitTimeBuyService.GetServiceSetting(); return(View(model)); }