public IActionResult Create([FromBody] CreateReminderItemViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var item = new ReminderItem( model.Id ?? Guid.NewGuid(), model.Title, model.Message, model.DateTimeUtc.GetValueOrDefault(), new User( model.UserLogin, model.UserChatId), model.Status ?? ReminderItemStatus.Created ); try { _storage.Add(item); return(Ok(new ReminderItemViewModel(item))); } catch (ArgumentException) { return(Conflict()); } }
private void OnMessageReceived(object sender, MessageReceiventEventArgs args) { var item = new ReminderItem(Guid.NewGuid(), args.Message.Header, args.Message.Text, args.Message.DateTimeUtc, args.UserId ); var items = new ReminderItem[] { item }; _storage.Add(items); }
private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { _logger.LogInformation("Received message from: {0}", args.Login); var item = new ReminderItem( Guid.NewGuid(), args.Message.Header, args.Message.Text, args.Message.DateTimeUtc, new User(args.Login, args.ChatId)); _storage.Add(item); _logger.LogInformation("Received message saved in storage with id: {0:N}", item.Id); }
public IActionResult Create([FromBody] CreateReminderItemViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var items = new ReminderItem[] { new ReminderItem(model.Id ?? Guid.NewGuid(), model.Title, model.Message, model.DateTimeUTC ?? DateTimeOffset.UtcNow, model.UserId) }; try { _storage.Add(items); } catch (ArgumentException) { return(Conflict()); } return(Ok(new ReminderItemViewModel(items))); }