Example #1
0
        public void AddPictureToOrder(byte[] content, int id)
        {
            var picture = new PhotosOrder()
            {
                UserPictures = content,
                OrderId      = id
            };

            this.userPictures.Add(picture);
            this.userPictures.SaveChanges();
        }
Example #2
0
        public IActionResult OnPostAddPhotoOrder(int picture_id)
        {
            photos.picture_id = picture_id;
            int SessionCookie = Convert.ToInt32(HttpContext.Session.GetString("LoginSession"));

            IdUser.user_id = SessionCookie;

            if (SessionCookie > 0)
            {
                PhotosOrder = SessionExtensions.Get <List <PhotosOrdered> >(HttpContext.Session, "PhotosOrder");
                if (PhotosOrder == null)
                {
                    new DBRepos().NewOrder(IdUser);
                    photos.order_id = new DBRepos().LastOrder(IdUser);
                    PhotosOrder     = new List <PhotosOrdered>();
                    PhotosOrder.Add(photos);
                    new DBRepos().PhotoOrder(photos);
                    SessionExtensions.Set(HttpContext.Session, "PhotosOrder", PhotosOrder);
                    return(Page());
                }
                else
                {
                    int index = Exists(PhotosOrder, picture_id);
                    if (index == -1)
                    {
                        photos.order_id = new DBRepos().LastOrder(IdUser);
                        PhotosOrder.Add(photos);
                        new DBRepos().PhotoOrder(photos);
                        SessionExtensions.Set(HttpContext.Session, "PhotosOrder", PhotosOrder);
                        return(Page());
                    }
                    else
                    {
                        return(Page()); //Misschien duidelijk aangeven dat hij er al in zat
                    }
                }
            }
            else
            {
                return(RedirectToPage("Login"));
            }
        }