public IActionResult Create(Categories categorie, ICollection <IFormFile> files) { if (HttpContext.Session.GetString("UserID") == null && HttpContext.Session.GetString("Email") == null) { return(RedirectToAction("Index", "Login")); } string tempImageURL = ""; if (ModelState.IsValid) { var uploads = Path.Combine(_environment.WebRootPath, "Image/categories"); foreach (var file in files) { if (file != null) { string URL = uploads + "/" + file.FileName; Bitmap img = convertImage.ResizeImage(Image.FromStream(file.OpenReadStream(), true, true), 620, 740); img.Save(URL); tempImageURL += "/Image/categories/" + file.FileName; } } categorie.Picture = tempImageURL; db.Categories.Add(categorie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(categorie)); }
public bool AddCustomer(Customers customer) { try { _context.Customers.Add(customer); _context.SaveChanges(); return(true); } catch { return(false); } }
public bool ChangeStatus(long id) { var user = db.Users.SingleOrDefault(x => x.UserId == id); user.IsActive = !user.IsActive; db.SaveChanges(); return(user.IsActive); }
public bool ChangeStatus(long id) { var cate = db.Categories.SingleOrDefault(x => x.CategoryId == id); cate.IsDisplay = !cate.IsDisplay; db.SaveChanges(); return(cate.IsDisplay); }
public bool ChangeStatus(long id) { var cate = db.Products.SingleOrDefault(x => x.ProductId == id); cate.IsDelete = !cate.IsDelete; db.SaveChanges(); return(cate.IsDelete); }
public IActionResult GetContactInfor([FromBody] Contacts contact) { if (contact != null) { _context.Add(contact); _context.SaveChanges(); return(new JsonResult(new { message = "success!" })); } return(new JsonResult(new { message = "Error!" })); }