public IActionResult Update([FromBody] Agendadata item) { if (item == null) { return(BadRequest()); } var agendadata = _context.Agendadata.FirstOrDefault(t => t.MessageId == item.MessageId); if (agendadata == null) { return(NotFound()); } //update alle values agendadata.Priority = item.Priority; agendadata.Description = item.Description; agendadata.EndDate = item.EndDate; agendadata.StartDate = item.StartDate; agendadata.EndTime = item.EndTime; agendadata.StartTime = item.StartTime; agendadata.Title = item.Title; _context.Agendadata.Update(agendadata); _context.SaveChanges(); return(new NoContentResult()); }
public IActionResult Create([FromBody] Agendadata item) { if (item == null) { return(BadRequest()); } var agendaitemhighid = _context.Agendadata.LastOrDefault(); item.MessageId = agendaitemhighid.MessageId + 1; item.State = "pending"; _context.Agendadata.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetAgendadata", new { id = item.MessageId }, item)); }
public async Task <Agendadata> Post([FromBody] Agendadata agendaitem) { var agenda = await GetAgenda(); var agendaList = agenda.ToList(); try { var highest = agendaList.LastOrDefault(); agendaitem.MessageId = highest.MessageId + 1; } catch { } agendaList.Add(agendaitem); await _storage.SaveAgendaData(agendaList, FILENAME); return(agendaitem); }