public Picture AddPicture(Picture picture)
 {
     if (picture.PictureId == 0)
     {
         return this.context.Pictures.Add(picture);
     }
     else
     {
         Picture pictureToUpdate = this.context.Pictures.Where(p => p.PictureId == picture.PictureId).FirstOrDefault();
         if (pictureToUpdate != null)
         {
             this.context.Entry(pictureToUpdate).CurrentValues.SetValues(picture);                    
         }
         return null;
     }   
 }
Example #2
0
 //ADDPICTURE & LIST OF PICTURES
 public async void AddPicture(Picture picture)
 {
     using (HttpClient client = new HttpClient())
     {
         try
         {
             string url = string.Format("{0}{1}", URL, "picture");
             string json = JsonConvert.SerializeObject(picture);
             HttpContent content = new StringContent(json);
             content.Headers.Clear();
             content.Headers.Add("Content-Type", "application/json");
             await client.PostAsync(url, content);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Example #3
0
 public async Task<Picture> GetPictureById(int id)
 {
     Picture picture = new Picture();
     using (HttpClient client = new HttpClient())
     {
         string url = string.Format("{0}{1}", URL, "/picture?id=" + id);
         using (HttpResponseMessage response = await client.GetAsync(url))
         {
             if (response.IsSuccessStatusCode)
             {
                 string content = await response.Content.ReadAsStringAsync();
                 picture = await JsonConvert.DeserializeObjectAsync<Picture>(content);
             }
         }
     }
     return picture;
 }
 public void UpdatePictureRating(Picture picture)
 {
     shredderService.AddPicture(picture);
 }
 public void SavePicture(Picture p)
 {
     shredderService.AddPicture(p);
 }
 public Picture AddPicture(Picture picture)
 {
     picture = uow.PictureRepository.AddPicture(picture);
     uow.Save();
     return picture;
 }