Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 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);
        }
Esempio n. 4
0
        public bool ChangeStatus(long id)
        {
            var cate = db.Categories.SingleOrDefault(x => x.CategoryId == id);

            cate.IsDisplay = !cate.IsDisplay;
            db.SaveChanges();
            return(cate.IsDisplay);
        }
Esempio n. 5
0
        public bool ChangeStatus(long id)
        {
            var cate = db.Products.SingleOrDefault(x => x.ProductId == id);

            cate.IsDelete = !cate.IsDelete;
            db.SaveChanges();
            return(cate.IsDelete);
        }
Esempio n. 6
0
 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!" }));
 }