public IActionResult Update(long id, [FromBody] RequestListItem item) { if (item == null || item.Id != id) { return(BadRequest()); } var RequestList = _context.RequestListItems.FirstOrDefault((t => t.Id == id)); if (RequestList == null) { return(NotFound()); } RequestList.IsComplete = item.IsComplete; RequestList.ProjectCode = item.ProjectCode; RequestList.LabLocation = item.LabLocation; RequestList.BillTo = item.BillTo; RequestList.ReportTo = item.ReportTo; RequestList.AEName = item.AEName; RequestList.JDECode = item.JDECode; RequestList.PercentOfProject = item.PercentOfProject; RequestList.LoginsAssociated = item.LoginsAssociated; RequestList.NewAEName = item.NewAEName; RequestList.DollarValue = item.DollarValue; RequestList.Name = item.Name; RequestList.Status = item.Status; RequestList.RequestDate = item.RequestDate; RequestList.PercOfPrjRequested = item.PercOfPrjRequested; RequestList.AEComments = item.AEComments; _context.RequestListItems.Update(RequestList); _context.SaveChanges(); return(new NoContentResult()); }
public IActionResult Create([FromBody] RequestListItem item) { //The[FromBody] attribute tells MVC to get the value of the to-do item from the body of the HTTP request. if (item == null) { return(BadRequest()); } _context.RequestListItems.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetRequestList", new { id = item.Id }, item)); }