Example #1
0
        public async Task <IActionResult> Put(int id, [FromBody] Item item)
        {
            if (ModelState.IsValid)
            {
                var itemUpdate = await _repo.FindBy(i => i.Id == id).SingleAsync();

                itemUpdate.Content   = item.Content;
                itemUpdate.Link      = item.Link;
                itemUpdate.PubDate   = item.PubDate;
                itemUpdate.Thumbnail = item.Thumbnail;
                itemUpdate.Title     = item.Title;
                _repo.Edit(itemUpdate);

                if (await _repo.SaveChangesAsync())
                {
                    return(Ok($"RSS item with id {itemUpdate.Id} updated successfully"));
                }
            }
            _logger.LogError($"Error saving item with id {id} to database");
            return(BadRequest("Putting data failed!"));
        }
Example #2
0
 public List <News> FindBy(Expression <Func <News, bool> > predicate)
 {
     return(NewsRepository.FindBy(predicate));
 }