示例#1
0
        public async Task <IActionResult> UpdateTime(string moniker, int id, [FromBody] TalkViewModel model)
        {
            try
            {
                var talk = _repo.GetTalk(id);
                var time = _repo.GetTimeSlots(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(talk));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to update talk time: {0}", ex);
            }

            return(BadRequest("Couldn't update talk."));
        }
 public IActionResult Get(string moniker)
 {
     return(Ok(_repo.GetTimeSlots(moniker)));
 }