public async Task <IActionResult> UpdateTime(string moniker, int id, [FromBody] TalkViewModel model)
        {
            try
            {
                var talk = await _repo.GetTalkAsync(id);

                var time = (await _repo.GetTimeSlotsAsync(moniker)).Where(r => r.Time == model.Time).FirstOrDefault();
                if (time == null || talk == null)
                {
                    return(NotFound("Cannot find talk."));
                }
                talk.TimeSlot = time;

                await _repo.SaveChangesAsync();

                return(Ok(true));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to update talk time: {0}", ex);
            }

            return(BadRequest("Couldn't update talk."));
        }
示例#2
0
 public async Task <IActionResult> Get(string moniker)
 {
     return(Ok(await _repo.GetTimeSlotsAsync(moniker)));
 }