public bool UpdateDealStatus(int dealId) { // Deals.CreatedDate = DateTime.Now; SA_Deals EditDeals = _context.SA_Deals.Where(Cat => Cat.id == dealId).FirstOrDefault(); if (EditDeals.status.HasValue) { if (EditDeals.status.Value == 1) { EditDeals.status = 2; } else { EditDeals.status = 1; } } else { EditDeals.status = 1; } _context.Entry(EditDeals).State = EntityState.Modified; int x = _context.SaveChanges(); return(x == 0 ? false : true); }
public ActionResult SaveDeals(SA_Deals UserDeals) { for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName); file.SaveAs(path); UserDeals.DealsImg = fileName; } } UserDeals.CreatedTime = DateTime.Now; DealsDataStore Obj = new DealsDataStore(); if (UserDeals.id == 0) { Obj.AddDeals(UserDeals); } else { Obj.EditDeals(UserDeals); } return(RedirectToAction("Deals")); }
public async Task <bool> UpdateDeals(SA_Deals Deals) { _context.Entry(Deals).State = EntityState.Modified; // Deals.ModeifiedDate = DateTime.Now; int x = await _context.SaveChangesAsync(); return(x == 0 ? false : true); }
public bool AddDeals(SA_Deals Deals) { // Deals.CreatedDate = DateTime.Now; _context.SA_Deals.Add(Deals); int x = _context.SaveChanges(); return(x == 0 ? false : true); }
public ActionResult SaveDeals(SA_Deals UserDeals) { for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName); file.SaveAs(path); UserDeals.DealsImg = fileName; } } UserDeals.status = 1; UserDeals.CreatedBy = Session["User"].ToString(); UserDeals.CreatedTime = UserDeals.CreatedTime != null? UserDeals.CreatedTime.Value: DateTime.Now; DealsDataStore Obj = new DealsDataStore(); if (UserDeals.id == 0) { Obj.AddDeals(UserDeals); string np = Request.Form["allProduct"].ToString(); foreach (string s in np.Split(',')) { if (s != "") { Obj.AddDealsProduct(new SA_DealsAndProductRelation { SA_DealID = UserDeals.id, SA_ProductId = Convert.ToInt16(s) }); } } } else { Obj.EditDeals(UserDeals); string np = Request.Form["allProduct"].ToString(); Obj.DeleteDealsProduct(UserDeals.id); foreach (string s in np.Split(',')) { if (s != "") { Obj.AddDealsProduct(new SA_DealsAndProductRelation { SA_DealID = UserDeals.id, SA_ProductId = Convert.ToInt16(s) }); } } } return(RedirectToAction("Deals")); }
public bool DeleteDeals(int DealsId) { // Deals.CreatedDate = DateTime.Now; SA_Deals EditDeals = _context.SA_Deals.Where(Deals => Deals.id == DealsId).FirstOrDefault(); _context.Entry(EditDeals).State = EntityState.Deleted; int x = _context.SaveChanges(); return(x == 0 ? false : true); }
public ActionResult EditDeals(int id) { DealsDataStore Obj = new DealsDataStore(); SA_Deals obj = Obj.GetDealsByid(id); List <SelectListItem> productList = Obj.GetProductList(); SA_DealsViewModel objSaCatV = new SA_DealsViewModel(); objSaCatV.id = obj.id; objSaCatV.DealsName = obj.DealsName; objSaCatV.DealsDiscription = obj.DealsDiscription; objSaCatV.URL = obj.URL; objSaCatV.MetaDiscription = obj.MetaDiscription; objSaCatV.Keywords = obj.Keywords; objSaCatV.ProductList = productList; objSaCatV.Product = obj.Product.ToString(); return(View("add-Deals", objSaCatV)); }
public bool EditDeals(SA_Deals Deals) { // Deals.CreatedDate = DateTime.Now; SA_Deals EditDeals = _context.SA_Deals.Where(Cat => Cat.id == Deals.id).FirstOrDefault(); EditDeals.DealsName = Deals.DealsName; EditDeals.DealsDiscription = Deals.DealsDiscription; EditDeals.URL = Deals.URL; EditDeals.MetaDiscription = Deals.MetaDiscription; EditDeals.MetaTitle = Deals.MetaTitle; EditDeals.Keywords = Deals.Keywords; EditDeals.Product = Deals.Product; EditDeals.CreatedTime = Deals.CreatedTime; if (Deals.DealsImg != null) { EditDeals.DealsImg = Deals.DealsImg; } _context.Entry(EditDeals).State = EntityState.Modified; int x = _context.SaveChanges(); return(x == 0 ? false : true); }