Ejemplo n.º 1
0
 public ReturnValue<bool> DeleteAdver(T_Adver iAdver)
 {
     try
     {
         _dataContext.T_Adver.Remove(iAdver);
         _dataContext.SaveChanges();
         return new ReturnValue<bool>(true, "");
     }
     catch (Exception)
     {
         return new ReturnValue<bool>(false, "");
     }
 }
Ejemplo n.º 2
0
 public ReturnValue<bool> AddNewAdver(T_Adver iAdver)
 {
     if (IsExist(iAdver)) return new ReturnValue<bool>(false, "Mục đã tồn tại");
     try
     {
         _dataContext.T_Adver.Add(iAdver);
         _dataContext.SaveChanges();
         return new ReturnValue<bool>(true, "");
     }
     catch (Exception)
     {
         return new ReturnValue<bool>(false, "");
     }
 }
Ejemplo n.º 3
0
        public ActionResult AddNew(T_Adver iAdver)
        {
            // Upload the image
            HttpPostedFileBase file = Request.Files["ImageData"];
            string PathReturn = UploadAdverImage(file);
            iAdver.ImagePath = PathReturn;
            ReturnValue<bool> result = new ReturnValue<bool>(false, "");

            if (ModelState.IsValid)
            {
                result = _AdverServices.AddNewAdver(iAdver);
            }
            if (result.RetValue)
            {
                return RedirectToAction("List", "Adver");
            }
            else
            {
                // Get Adver_List again
                ModelState.AddModelError("Error", result.Msg);
                return View(iAdver);
            }
        }
Ejemplo n.º 4
0
 public T_Adver AddNewAdverAndReturn(T_Adver iAdver)
 {
     _dataContext.T_Adver.Add(iAdver);
         _dataContext.SaveChanges();
         return iAdver;
 }
Ejemplo n.º 5
0
 public ReturnValue<bool> UpdateAdver(T_Adver iAdver)
 {
     //if (IsExist(iAdver)) return new ReturnValue<bool>(false, "Mục đã tồn tại");
     try
     {
         _dataContext.Entry(iAdver).State = EntityState.Modified;
         return new ReturnValue<bool>(_dataContext.SaveChanges() > 0, "");
     }
     catch (Exception)
     {
         return new ReturnValue<bool>(false, "");
     }
 }
Ejemplo n.º 6
0
 public bool IsExist(T_Adver iAdver)
 {
     return false;
 }
Ejemplo n.º 7
0
        public ActionResult Edit(T_Adver iAdver)
        {
            // Upload image if it have
            HttpPostedFileBase file = Request.Files["ImageData"];
            string PathReturn = UploadAdverImage(file);
            if (!string.IsNullOrEmpty(PathReturn)) iAdver.ImagePath = PathReturn;

            iAdver.ModifiedDate = DateTime.Now;
            iAdver.ModifiedBy = "admin";
            ReturnValue<bool> result = _AdverServices.UpdateAdver(iAdver);
            if (result.RetValue)
            {
                return RedirectToAction("List", "Adver");
            }
            else
            {
                // Get Adver_List again
                ModelState.AddModelError("Error", result.Msg);
                return View(iAdver);
            }
        }