예제 #1
0
        public IActionResult EditSent(int id)
        {
            var order = _context.Order.Find(id);

            order.IsSent = !order.IsSent;
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IActionResult ChangeUserPassword(string password)
        {
            var user = _db.User.Find((_binaryHelper.FromBinary <User>(HttpContext.Session.Get("User"))).UserId);

            user.Password = _hashHelper.GetMD5(password);
            _db.SaveChanges();
            HttpContext.Session.Clear();
            return(RedirectToAction("UserLogin"));
        }
예제 #3
0
        public void Index(int productId, int productAttributeId, string value)
        {
            var productAttributeValue = new ProductAttributeValue();

            productAttributeValue.ProductId          = productId;
            productAttributeValue.ProductAttributeId = productAttributeId;
            productAttributeValue.Value = value;
            _context.ProductAttributeValue.Add(productAttributeValue);
            _context.SaveChanges();
            HttpContext.Response.Redirect($"/productattributevalues/{productId}");
        }
예제 #4
0
 public void Index(int productId, IFormFile[] photoFiles)
 {
     if (productId != 0)
     {
         HttpContext.Session.SetInt32("Id", productId);
     }
     else if (HttpContext.Session.Keys.Contains("Id"))
     {
         productId = (int)HttpContext.Session.GetInt32("Id");
     }
     if (photoFiles != null)
     {
         foreach (var photoFile in photoFiles)
         {
             var          productPhoto  = new ProductPhoto();
             string       photoFilename = $"{Guid.NewGuid().ToString()}.jpg";
             MemoryStream stream        = new MemoryStream();
             photoFile.CopyTo(stream);
             new ImageFactory().Load(stream.GetBuffer())
             .Resize(new Size(721, 466))
             .Format(new JpegFormat())
             .Save($"{_hostEnvironment.ContentRootPath}\\wwwroot\\files\\productphotos\\{photoFilename}");
             productPhoto.PhotoFilename = photoFilename;
             productPhoto.ProductId     = productId;
             _context.ProductPhoto.Add(productPhoto);
         }
         _context.SaveChanges();
     }
     HttpContext.Response.Redirect($"/productphotoes/{productId}");
 }
        public void Delete(int id)
        {
            var orderDetail = _context.OrderDetail.Find(id);
            int orderId     = orderDetail.OrderId;

            _context.OrderDetail.Remove(orderDetail);
            _context.SaveChanges();
            HttpContext.Response.Redirect($"/orderdetails/{orderId}");
        }