Ejemplo n.º 1
0
 public IActionResult CreateRoom(CreateRoomRequest request)
 {
     if (ModelState.IsValid)
     {
         Room room = new Room
         {
             Name        = request.Name,
             NoArmChairs = request.ArmChairs,
             RoomId      = Guid.NewGuid().ToString()
         };
         AdministrationRepository.AddRoom(room);
         for (int i = 0; i < request.ArmChairs; i++)
         {
             ArmChair armChair = new ArmChair
             {
                 ArmChairId = Guid.NewGuid().ToString(),
                 No         = i + 1
             };
             ArmChairByRoom armChairByRoom = new ArmChairByRoom
             {
                 ArmChairId       = armChair.ArmChairId,
                 RoomId           = room.RoomId,
                 ArmChairByRoomId = Guid.NewGuid().ToString(),
                 StateArmChair    = StateArmChair.ready
             };
             AdministrationRepository.AddArmChair(armChair);
             AdministrationRepository.AddArmChairByRoom(armChairByRoom);
         }
         return(RedirectToAction("GetRooms"));
     }
     foreach (var error in ModelState.Values)
     {
         foreach (var item in error.Errors)
         {
             Logger.LogError(item.ErrorMessage);
         }
     }
     return(RedirectToAction("GetRooms"));
 }