public ActionResult SaveAdvert(Advert model) { AdvertBLL bll = new AdvertBLL(); bll.Add(model); return View(); }
public bool Delete(Advert item) { using (ISession session = NHibernateHelper.OpenSession()) { ITransaction tran = session.BeginTransaction(); session.Delete(item); tran.Commit(); return true; } }
public bool Delete(Advert item) { try { return dal.Delete(item); } catch (Exception ex) { CommonLoger.Error(ex.ToString()); return false; } }
public ActionResult AdvertEdit(int AdvertID = 0, Advert model = null) { ViewBag.AmIn = "apk"; AdminUserBLL bll = new AdminUserBLL(); AdvertBLL advertBLL = new AdvertBLL(); if (AdvertID == 0) { ViewBag.STitle = "添加"; } else { ViewBag.STitle = "编辑"; } if (Request["ID"] == null) { IList<AdminUserNameIDDto> list = bll.GetAdminUserNameIDsByRoleType(RoleType.商务); ViewBag.UserList = list; if (AdvertID == 0) { ViewBag.Advert = new Advert(); return View(); } else { Advert ad = advertBLL.Get(AdvertID); ViewBag.Advert = ad; return View(); } } else { if (string.IsNullOrEmpty(model.AdName)) { IList<AdminUserNameIDDto> list = bll.GetAdminUserNameIDsByRoleType(RoleType.商务); ViewBag.UserList = list; ViewBag.Message = "广告主名称不能为空";//保存要提示的消息 if (AdvertID == 0) { ViewBag.Advert = new Advert(); } else { ViewBag.Advert = advertBLL.Get(AdvertID); } return View(); } if (advertBLL.AdvertIsExists(model.AdName, model.ID)) { IList<AdminUserNameIDDto> list = bll.GetAdminUserNameIDsByRoleType(RoleType.商务); ViewBag.UserList = list; ViewBag.Message = "广告主名称已存在";//保存要提示的消息 if (AdvertID == 0) { ViewBag.Advert = new Advert(); } else { ViewBag.Advert = advertBLL.Get(AdvertID); } return View(); } if (model.ID == 0) { model.CreateTime = DateTime.Now; advertBLL.Add(model); } else { advertBLL.Update(model); } return RedirectToAction("Advert", "Home"); } }