예제 #1
0
        public JsonResult DeleteRoomInConstruction(ParemetersRoom paremetersRoom, ParemetersRange paremetersRange)
        {
            Room room = ApplicationContext.Rooms.AsNoTracking().FirstOrDefault(x => x.Id == paremetersRoom.RoomId);

            if (room != null && room.Id == paremetersRoom.RoomId)
            {
                ApplicationContext.Rooms.Remove(room);
                ApplicationContext.SaveChanges();
            }

            return(GetRoomsInConstruction(paremetersRoom, paremetersRange));
        }
예제 #2
0
        public JsonResult EditRoomInConstruction(ParemetersRoom paremetersRoom, ParemetersRange paremetersRange)
        {
            Room room = ApplicationContext.Rooms.AsNoTracking().FirstOrDefault(x => x.Id == paremetersRoom.RoomId);

            if (room != null && room.Id == paremetersRoom.RoomId)
            {
                room.Name  = paremetersRoom.Name;
                room.Floor = paremetersRoom.Floor;
                ApplicationContext.Rooms.Update(room);
                ApplicationContext.SaveChanges();
            }

            return(GetRoomsInConstruction(paremetersRoom, paremetersRange));
        }
예제 #3
0
        public JsonResult AddRoomInConstruction(ParemetersRoom paremetersRoom, ParemetersRange paremetersRange)
        {
            Room room = new Room
            {
                Name           = paremetersRoom.Name,
                Floor          = paremetersRoom.Floor,
                ConstructionId = paremetersRoom.ConstructionId
            };

            ApplicationContext.Rooms.Add(room);
            ApplicationContext.SaveChanges();

            return(GetRoomsInConstruction(paremetersRoom, paremetersRange));
        }
예제 #4
0
        //Rooms
        public JsonResult GetRoomsInConstruction(ParemetersRoom paremetersRoom, ParemetersRange paremetersRange)
        {
            var rooms = ApplicationContext.Rooms.AsNoTracking().Where(x => x.ConstructionId == paremetersRoom.ConstructionId).Include(x => x.Machines)
                        .Select(x => new
            {
                id             = x.Id,
                name           = x.Name,
                floor          = x.Floor,
                constructionId = x.ConstructionId,
                haveMachine    = x.Machines.Any()
            }).Skip(paremetersRange.Skip).Take(paremetersRange.Take);

            return(Json(rooms));
        }