public async Task <int> Create(UserContentDetails item) { try { item.CreatedOn = System.DateTime.Now; item.ModifiedOn = System.DateTime.Now; _context.UserContentDetails.Add(item); try { await _context.SaveChangesAsync(); Console.WriteLine("Obtained ID is {0}", item.ContentId); Console.WriteLine("Obtained content is {0}", item.Content); Console.WriteLine("Obtained tag is {0}", item.MetaTags); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(item.ContentId); } catch (Exception ex) { throw new Exception(ex.Message); } }
[HttpGet("{userID}")] //gets all the data that matches with the prescribed UserID public async Task <UserContentDetails> GetallbyUserID(int UserID, [FromBody] UserContentDetails item) { try{ UserContentDetails todo = await _context.UserContentDetails.FirstOrDefaultAsync(t => t.UserID == UserID); return(todo); }catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task Post(UserContentDetails item) { try { item.CreatedOn = System.DateTime.Now; item.ModifiedOn = System.DateTime.Now; _context.UserContentDetails.Add(item); await _context.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async Task <List <UserContentDetails> > GetByID(int id) { UserContentDetails objectScore = await _context.UserContentDetails.FirstOrDefaultAsync(pi => pi.ContentId == id); List <UserContentDetails> product = new List <UserContentDetails>(); try { product.Add(objectScore); } catch (Exception ex) { throw new Exception(ex.Message); } return(product); }
public async Task <int> Update(int id, UserContentDetails item) { try { var result = _context.UserContentDetails.FirstOrDefault(t => t.ContentId == id); result.Content = item.Content; result.MetaTags = item.MetaTags; result.IsPrivate = item.IsPrivate; result.IsGraphCreated = item.IsGraphCreated; result.IsFavourites = item.IsFavourites; result.IsDelete = item.IsDelete; _context.UserContentDetails.Update(result); await _context.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(0); }
public Task <int> Create([FromBody] UserContentDetails item) { return(_service.Create(item)); }
public Task <int> Put(int id, [FromBody] UserContentDetails item) { return(_service.Update(id, item)); }
[HttpGet("getallbycontentID/{contentID}")] //gets all the data that matches with the prescribed //contentID from the Content Details table public /*async Task<UserContentDetails>*/ IActionResult GetallbyContentID(int ContentID, [FromBody] UserContentDetails item) { try{ var todo = _context.UserContentDetails.FirstOrDefaultAsync(t => t.ContentID == ContentID); return(new ObjectResult(todo)); }catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <UserContentDetails> GetbyUserID(int UserID, [FromBody] UserContentDetails item) { UserContentDetails todo = await _context.UserContentDetails.FirstOrDefaultAsync(t => t.UserID == UserID); return(todo); }