예제 #1
0
 public async Task <IActionResult> AddChatRoom(ManageChatsViewModel chatModel)
 {
     // TODO
     if (ModelState.IsValid)
     {
         // create chat room
         var newChat = new ChatRoom()
         {
             ChatName      = chatModel.Chat.ChatName,
             UnixTimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
         };
         // add to repo
         await chatRepo.CreateChatRoom(newChat);
     }
     else
     {
         ModelState.AddModelError(nameof(ManageChatsViewModel.Chat.ChatName), "Invalid title");
         return(RedirectToAction("ManageChats", new
         {
             chatModel = chatModel
         }));
     }
     return(RedirectToAction("ManageChats"));
 }