public IActionResult Create([FromBody] MotdItem item) { if (item == null) { Console.WriteLine("MITÄ VITTU"); return(BadRequest()); } m_context.MotdItems.Add(item); m_context.SaveChanges(); return(CreatedAtRoute("GetMotd", new { ID = item.ID }, item)); }
public IActionResult Update(long ID, [FromBody] MotdItem item) { if (item == null || item.ID != ID) { return(BadRequest()); } var motd = m_context.MotdItems.FirstOrDefault(t => t.ID == ID); if (motd == null) { return(NotFound()); } motd.Data = item.Data; motd.Type = item.Type; m_context.MotdItems.Update(motd); m_context.SaveChanges(); return(new NoContentResult()); }