Beispiel #1
0
        public async Task <SharedLookUpResponse> UpdateComponentAsync(UpdateFloorRoomAc updateRoom)
        {
            var floorRooms = await iMSDbContext.FloorRooms.Where(x => x.Id != updateRoom.Id).ToListAsync();

            var isDuplicated = floorRooms.Any(x => x.RoomNo.ToLowerInvariant() == updateRoom.RoomNo.ToLowerInvariant());

            if (isDuplicated)
            {
                return new SharedLookUpResponse()
                       {
                           HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Duplicate No of Room, please use unique code"
                       }
            }
            ;
            else
            {
                var floorRoom = await iMSDbContext.FloorRooms.FirstAsync(x => x.Id == updateRoom.Id);

                floorRoom.RoomNo    = updateRoom.RoomNo;
                floorRoom.RoomType  = updateRoom.RoomType;
                floorRoom.BedAmount = updateRoom.BedAmount;
                floorRoom.Status    = updateRoom.Status;
                iMSDbContext.FloorRooms.Update(floorRoom);
                await iMSDbContext.SaveChangesAsync();

                return(new SharedLookUpResponse()
                {
                    HasError = false, Message = "Room info updated successfully"
                });
            }
        }
Beispiel #2
0
 public async Task <IActionResult> UpdateRoomAsync([FromBody] UpdateFloorRoomAc updateRoom)
 {
     if (string.IsNullOrEmpty(updateRoom.RoomNo.Trim()))
     {
         return(Ok(new SharedLookUpResponse()
         {
             HasError = true,
             ErrorType = SharedLookUpResponseType.Name,
             Message = "Room No can't be null or empty"
         }));
     }
     else
     {
         if (await iMSDbContext.FloorRooms.AnyAsync(x => x.Id == updateRoom.Id))
         {
             return(Ok(await floorRoomManagementRepository.UpdateComponentAsync(updateRoom)));
         }
         else
         {
             return(Ok(new SharedLookUpResponse()
             {
                 HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Room Info not found"
             }));
         }
     }
 }