public async Task <IActionResult> Post(long chatId) { BotUser user = new BotUser() { ChatId = chatId }; if (db.BotUsers.Any(b => b.ChatId == user.ChatId)) { return(BadRequest()); } db.BotUsers.Add(user); await db.SaveChangesAsync(); string uri = String.Format(AppSettings.Url, "api/1.0.0/users/") + user.ChatId.ToString(); return(Created(uri, user)); }
public async Task <IActionResult> Post(int userId) { BotUser user = new BotUser() { Id = userId }; if (db.ApplyFilterRequests.Any(b => b.UserId == user.Id)) { return(BadRequest("Cannot create an existing request.")); } ApplyFilterRequest applyFilterRequest = new ApplyFilterRequest() { UserId = user.Id }; db.ApplyFilterRequests.Add(applyFilterRequest); await db.SaveChangesAsync(); string uri = String.Format(AppSettings.Url, "api/1.0.0/apply-filter-requests/") + user.Id.ToString(); return(Created(uri, applyFilterRequest)); }