Exemplo n.º 1
0
        public static RoomsModel EntityToModel(this Rooms entity, bool virtualActive = false)
        {
            try
            {
                RoomsModel model = new RoomsModel()
                {
                    BlockFloorId = entity.BlockFloorId,
                    Number = entity.Number,
                    RoomTypeId = entity.RoomTypeId,
                    IsActive = entity.IsActive,
                    Id = entity.Id
                };
                if (virtualActive)
                {
                    model.RoomSales = entity.RoomSales;
                    model.BlockFloor = entity.BlockFloor;
                    model.RoomSales = entity.RoomSales;
                    model.RoomStatuses = entity.RoomStatuses;
                    model.RoomType = entity.RoomType;

                }
                return model;
            }
            catch (Exception)
            {

                return new RoomsModel();
            }
        }
        public ActionResult RoomInsert(RoomsModel roomModel, int[] StatusList)
        {
            Rooms room = roomModel.ModelToEnity();
            room.IsActive = true;
            _serviceRooms.Insert(room);
            RoomStatuses roomstatus = new RoomStatuses();
            foreach (var item in StatusList)
            {
                roomstatus.RoomId = room.Id;
                roomstatus.IsActive = true;
                roomstatus.StatusId = item;
                _serviceRoomStatuses.Insert(roomstatus);

            }
            return RedirectToAction("RoomList");
        }
        public ActionResult RoomEdit(RoomsModel room, int[] StatusList)
        {
            Rooms rooms = room.ModelToEnity();
            rooms.IsActive = true;
            _serviceRooms.Update(rooms);
            foreach (var item in StatusList)
            {
                RoomStatuses rs = new RoomStatuses();
                rs.RoomId = rooms.Id;
                rs.StatusId = item;
                _serviceRoomStatuses.Insert(rs);
            }

            return RedirectToAction("RoomList");
        }