コード例 #1
0
ファイル: HomeController.cs プロジェクト: sclynton/CrazyBull
 public ActionResult SaveAdvert(Advert model)
 {
     
     AdvertBLL bll = new AdvertBLL();
     bll.Add(model);
     return View();
 }
コード例 #2
0
ファイル: AdvertDAL.cs プロジェクト: sclynton/CrazyBull
 public bool Delete(Advert item)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         ITransaction tran = session.BeginTransaction();
         session.Delete(item);
         tran.Commit();
         return true;
     }
 }
コード例 #3
0
ファイル: AdvertBLL.cs プロジェクト: sclynton/CrazyBull
 public bool Delete(Advert item)
 {
     try
     {
         return dal.Delete(item);
     }
     catch (Exception ex)
     {
         CommonLoger.Error(ex.ToString());
         return false;
     }
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: sclynton/CrazyBull
        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");
            }
        }