Exemple #1
0
        public static async Task <HttpStatusCode> UpdateNewsAsync(libraryNaturguiden.News news)
        {
            Setup();
            HttpResponseMessage response = await client.PutAsJsonAsync($"api/News/{news.Id}", news);

            response.EnsureSuccessStatusCode();

            return(response.StatusCode);
        }
Exemple #2
0
        public static async Task <libraryNaturguiden.News> GetNewsAsync(int id)
        {
            Setup();
            libraryNaturguiden.News news     = null;
            HttpResponseMessage     response = await client.GetAsync("api/News/" + id);

            if (response.IsSuccessStatusCode)
            {
                news = await response.Content.ReadAsAsync <libraryNaturguiden.News>();
            }
            return(news);
        }
Exemple #3
0
        internal void EditNews(libraryNaturguiden.News news)
        {
            var newsToAdd = db.News.Where(x => x.Id == news.Id).FirstOrDefault();

            if (newsToAdd != null)
            {
                newsToAdd.Id       = news.Id;
                newsToAdd.Date     = news.Date;
                newsToAdd.Creator  = news.Creator;
                newsToAdd.Heading  = news.Heading;
                newsToAdd.Text     = news.Text;
                newsToAdd.Picture  = news.PictureId;
                newsToAdd.LinkUrl  = news.LinkUrl;
                newsToAdd.LinkText = news.LinkText;
                newsToAdd.Position = news.Position;
                db.SaveChanges();
            }
        }
Exemple #4
0
        internal void AddNews(libraryNaturguiden.News news)
        {
            var newsToAdd = new News
            {
                Id       = news.Id,
                Date     = news.Date,
                Creator  = news.Creator,
                Heading  = news.Heading,
                Text     = news.Text,
                Picture  = news.PictureId,
                LinkUrl  = news.LinkUrl,
                LinkText = news.LinkText,
                Position = news.Position
            };

            db.News.Add(newsToAdd);
            db.SaveChanges();
        }
 public void Put(libraryNaturguiden.News news)
 {
     newsHandler.EditNews(news);
 }
 public void Post(libraryNaturguiden.News news)
 {
     newsHandler.AddNews(news);
 }