コード例 #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));
        }
コード例 #2
0
ファイル: MyDao.cs プロジェクト: war-man/TLCNNg2API
 public bool AddCustomer(Customers customer)
 {
     try
     {
         _context.Customers.Add(customer);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
        public bool ChangeStatus(long id)
        {
            var user = db.Users.SingleOrDefault(x => x.UserId == id);

            user.IsActive = !user.IsActive;
            db.SaveChanges();
            return(user.IsActive);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: apiController.cs プロジェクト: war-man/TLCNNg2API
 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!" }));
 }