/// <summary> /// 更新信息 /// </summary> public int UpdateInfo(SqlTransaction trans, SMSTemplateModel smsModel, int SMSTemplateId) { string key = "Cache_SMSTemplate_Model_" + SMSTemplateId; CacheHelper.RemoveCache(key); return(smsDAL.UpdateInfo(trans, smsModel, SMSTemplateId)); }
public ActionResult Edit(int id) { SMSTemplateModel model = Db.Where <SMSTemplateModel>(m => m.Id == id).FirstOrDefault(); var countries = Db.Select <Country>(); ViewData["Countries"] = countries; return(View("Add", model)); }
/// <summary> /// 从缓存读取信息 /// </summary> public SMSTemplateModel GetCacheInfo(SqlTransaction trans, int SMSTemplateId) { string key = "Cache_SMSTemplate_Model_" + SMSTemplateId; object value = CacheHelper.GetCache(key); if (value != null) { return((SMSTemplateModel)value); } else { SMSTemplateModel smsModel = smsDAL.GetInfo(trans, SMSTemplateId); CacheHelper.AddCache(key, smsModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null); return(smsModel); } }
public ActionResult Add(int country_id) { SMSTemplateModel model = new SMSTemplateModel(); var countries = Db.Select <Country>(); var c = countries.Where(x => x.Id == country_id).FirstOrDefault(); if (c == null) { return(Redirect("/")); } model.CountryCode = c.Code; ViewData["Countries"] = countries; return(View(model)); }
public ActionResult Update(SMSTemplateModel model, IEnumerable <HttpPostedFileBase> FileUp) { var countries = Db.Select <Country>(); ViewData["Countries"] = countries; if (string.IsNullOrEmpty(model.Name)) { ViewBag.Error = "Please enter SMS Internal name"; return(View("Add", model)); } if (string.IsNullOrEmpty(model.SystemName)) { model.SystemName = model.Name.ToSeoUrl(); } if (string.IsNullOrEmpty(model.Content)) { ViewBag.Error = "Please enter SMS content"; return(View("Add", model)); } // validate existing var v = Db.Select <SMSTemplateModel>(x => x.Where(m => m.Id != model.Id && m.CountryCode == model.CountryCode && m.SystemName == model.SystemName).Limit(1)).FirstOrDefault(); if (v != null) { ViewBag.Error = "Please use difference System Name."; return(View("Add", model)); } SMSTemplateModel current_item = new SMSTemplateModel(); if (model.Id > 0) { var z = Db.Select <SMSTemplateModel>(x => x.Where(m => m.Id == model.Id).Limit(1)); if (z.Count == 0) { // the ID is not exist ViewBag.Error = "We can not find your SMS Template"; return(View("Add", model)); } else { current_item = z.First(); } } if (model.Id == 0) { model.CreatedOn = DateTime.Now; model.CreatedBy = AuthenticatedUserID; } else { model.CreatedOn = current_item.CreatedOn; model.CreatedBy = current_item.CreatedBy; } if (model.Id == 0) { Db.Insert <SMSTemplateModel>(model); } else { Db.Update <SMSTemplateModel>(model); } return(RedirectToAction("Index")); }
/// <summary> /// 插入信息 /// </summary> public int InsertInfo(SqlTransaction trans, SMSTemplateModel smsModel) { return(smsDAL.InsertInfo(trans, smsModel)); }