Beispiel #1
0
        public ActionResult Create(FormCollection fc, CMS_AdImages obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    CMS_AdImages_DAO objDAO     = new CMS_AdImages_DAO();
                    CSF_Users_DAO    objUserDao = new CSF_Users_DAO();
                    int userID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
                    obj.UserCreate = userID;

                    int ReturnID = objDAO.Insert(obj);

                    if (ReturnID > 0)
                    {
                        SetAlert("Thêm ảnh quảng cáo thành công", AlertType.Success);
                        return(RedirectToAction("Index", "CMS_AdImages"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Thêm ảnh quảng cáo không thành công");
                    }
                    return(View("Index"));
                }
                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
                Logs.WriteLog(ex);
                return(View());
            }
        }
Beispiel #2
0
 public ActionResult Edit(FormCollection fc, CMS_AdImages obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_AdImages_DAO objDAO = new CMS_AdImages_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_AdImages"));
             }
             else
             {
                 SetAlert("Cập nhật không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Beispiel #3
0
 public int Insert(CMS_AdImages entity)
 {
     try
     {
         entity.CreateDate = System.DateTime.Now;
         MyContext.CMS_AdImages.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Beispiel #4
0
 public bool Update(CMS_AdImages entity)
 {
     try
     {
         CMS_AdImages obj = MyContext.CMS_AdImages.Find(entity.ID);
         obj.Name        = entity.Name;
         obj.Description = entity.Description;
         obj.Publish     = entity.Publish;
         obj.Orders      = entity.Orders;
         obj.FileName    = entity.FileName;
         obj.Location    = entity.Location;
         obj.Url         = entity.Url;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }