public ActionResult Put([FromBody] PicturesDTO picturesDto)
        {
            if (PicturesDAO.Update(picturesDto))
            {
                return(Ok());
            }

            return(BadRequest());
        }
Esempio n. 2
0
 public static PicturesDTO Post(PicturesDTO pictures)
 {
     using (SqlConnection connection = DataBase.GetConnection())
     {
         connection.Open();
         SqlCommand command = connection.CreateCommand();
         command.CommandText = REQ_POST;
         command.Parameters.AddWithValue($@"{FIELD_ID_RECIPE}", pictures.IdRecipe);
         command.Parameters.AddWithValue($@"{FIELD_PICTURE}", pictures.Picture);
         pictures.IdPicture = (int)command.ExecuteScalar();
     }
     return(pictures);
 }
Esempio n. 3
0
        public async Task <ActualResult> UpdateAsync(PicturesDTO dto)
        {
            try
            {
                _context.Entry(_mapper.Map <Pictures>(dto)).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(new ActualResult());
            }
            catch (Exception e)
            {
                return(new ActualResult(e.Message));
            }
        }
Esempio n. 4
0
        public static bool Update(PicturesDTO picture)
        {
            bool hasBeenChanged = false;

            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = connection.CreateCommand();
                command.CommandText = REQ_UPDATE;
                command.Parameters.AddWithValue($"{FIELD_ID_RECIPE}", picture.IdRecipe);
                command.Parameters.AddWithValue($"{FIELD_PICTURE}", picture.Picture);
                command.Parameters.AddWithValue($"{FIELD_ID_PICTURE}", picture.IdPicture);

                hasBeenChanged = command.ExecuteNonQuery() == 1;
            }

            return(hasBeenChanged);
        }
Esempio n. 5
0
        public async Task <ActualResult <string> > CreateAsync(PicturesDTO dto)
        {
            try
            {
                var mapping = _mapper.Map <Pictures>(dto);
                await _context.Pictures.AddAsync(mapping);

                await _context.SaveChangesAsync();

                return(new ActualResult <string> {
                    Result = mapping.HashId
                });
            }
            catch (Exception e)
            {
                return(new ActualResult <string>(e.Message));
            }
        }
Esempio n. 6
0
        public List <PicturesDTO> GetMovies()
        {
            Categories c = new Categories {
                Description = "Horror",
                Id          = 0
            };
            List <Categories> listaCategorias = new List <Categories>();
            PicturesDTO       p = new PicturesDTO
            {
                category       = "Action",
                Id             = 0,
                picture_path   = "../Content/Pictures/ironman1.jpg",
                thumbnail_path = "../Content/ThumbNails/ironman1Icon.png",
                title          = "Iron Man 1",
                description    = "A great movie about a men in an armor",
                punctuation    = 4
            };

            PicturesDTO p1 = new PicturesDTO
            {
                category       = "Drama",
                Id             = 1,
                picture_path   = "../Content/Pictures/thegodfather.jpg",
                thumbnail_path = "../Content/ThumbNails/thegodfather.png",
                title          = "The Godfather",
                description    = "A movie of big mobster boss",
                punctuation    = 5
            };

            PicturesDTO p2 = new PicturesDTO
            {
                category       = "Comedy",
                Id             = 2,
                picture_path   = "../Content/Pictures/scary2.jpg",
                thumbnail_path = "../Content/ThumbNails/scaryIcon.png",
                title          = "Scary Movie 2",
                description    = "The horror in the whole sense of the word",
                punctuation    = 1
            };
            PicturesDTO p3 = new PicturesDTO
            {
                category       = "Action",
                Id             = 3,
                picture_path   = "../Content/Pictures/ironman2.jpg",
                thumbnail_path = "../Content/ThumbNails/Ironman2Icon.png",
                title          = "iron Man 2",
                description    = "The secuel of the men in the armor",
                punctuation    = 5
            };
            PicturesDTO p4 = new PicturesDTO
            {
                category       = "Action",
                Id             = 4,
                picture_path   = "../Content/Pictures/venom.jpg",
                thumbnail_path = "../Content/ThumbNails/venom.jpg",
                title          = "Venom",
                description    = "A venom actually",
                punctuation    = 3
            };
            PicturesDTO p5 = new PicturesDTO
            {
                category       = "Drama",
                Id             = 5,
                picture_path   = "../Content/Pictures/shawshank.jpg",
                thumbnail_path = "../Content/ThumbNails/The-Shawshank-Redemption-icon.png",
                title          = "Shawshank redemption",
                description    = "A great story about a men unfairly imprisoned",
                punctuation    = 5
            };

            List <PicturesDTO> pictures = new List <PicturesDTO>();

            pictures.Add(p);
            pictures.Add(p1);
            pictures.Add(p2);
            pictures.Add(p3);
            pictures.Add(p4);
            pictures.Add(p5);
            return(pictures);
        }
 public PicturesDTO Post([FromBody] PicturesDTO picturesDto)
 {
     return(PicturesDAO.Post(picturesDto));
 }