public ActionResult <AssignedRoomDetail> UpdateAssignedRoom(long id, [FromBody] AssignedRoom updatedAssignedRoom)
        {
            var assignedRoom       = this.AssignedRoomRepository.Update(id, updatedAssignedRoom);
            var assignedRoomResult = this.mapper.Map <AssignedRoomDetail>(assignedRoom);

            return(assignedRoomResult);
        }
        public ActionResult <AssignedRoomDetail> CreateAssignedRoom(AssignedRoom newAssignedRoom)
        {
            var assignedRoom = this.mapper.Map <AssignedRoom>(newAssignedRoom);

            assignedRoom = this.AssignedRoomRepository.Create(assignedRoom);
            return(this.mapper.Map <AssignedRoomDetail>(assignedRoom));
        }
Beispiel #3
0
        public AssignedRoom Update(long id, AssignedRoom newAssignedRoom)
        {
            newAssignedRoom.Id = id;
            this.context.Entry(newAssignedRoom).State = EntityState.Modified;
            this.context.SaveChanges();

            return(newAssignedRoom);
        }
Beispiel #4
0
        public IActionResult RoomAssignForm(AssignedRoomViewModel assignforminfo)
        {
            var check1 = dbc.AvailableRoom.Where(q => q.Available > 0).ToList();

            check1.Insert(0, new AvailableRoom {
                RoomID = 0, RoomName = "Choose Room"
            });
            ViewBag.chooseroom = check1;
            if (assignforminfo.roomidVM == 0)
            {
                ViewBag.message3 = "Please choose a room!";
                return(View());
            }
            var matchstudent = dbc.Student.Where(q => q.StudentHallID == assignforminfo.studenthallidVM).FirstOrDefault();

            if (matchstudent == null)
            {
                ViewBag.message1 = "Invalid ID";
                return(View());
            }

            var checkifassigned = dbc.AssignedRoom.Where(q => q.StudentHallID == assignforminfo.studenthallidVM).FirstOrDefault();

            if (checkifassigned != null)
            {
                ViewBag.message2 = "Already Assigned!";
                return(View());
            }

            var          getroomname = dbc.AvailableRoom.Where(q => q.RoomID == assignforminfo.roomidVM).FirstOrDefault();
            AssignedRoom assign      = new AssignedRoom();

            assign.StudentHallID = assignforminfo.studenthallidVM;
            assign.StudentName   = matchstudent.StudentName;
            assign.RoomID        = assignforminfo.roomidVM;
            assign.RoomName      = getroomname.RoomName;
            assign.Department    = matchstudent.Department;
            assign.Date          = DateTime.Now;
            dbc.AssignedRoom.Add(assign);
            dbc.SaveChanges();
            ModelState.Clear();
            var getroomname2 = dbc.AvailableRoom.Where(q => q.RoomID == assign.RoomID).FirstOrDefault();

            getroomname2.Available = getroomname2.Available - 1;
            dbc.AvailableRoom.Update(getroomname2);
            dbc.SaveChanges();
            return(View());
        }
Beispiel #5
0
    private void SetRoomSize(AssignedRoom room)
    {
        if (room.inhabitants.Count == 0)
        {
            room.size = 1;
            return;
        }
        float baseSize = DetermineSizeForMonsterType(room.inhabitants[0].generalType, room.inhabitants.Count);

        baseSize *= room.grandiosity * globalSpaceMultiplier;
        if (room is CommonSpace)
        {
            baseSize /= 2;
        }
        if (baseSize < 1)
        {
            baseSize = 1;
        }
        room.size = Mathf.Floor(baseSize);
    }
Beispiel #6
0
    public static int GetBedType(AssignedRoom room)
    {
        int bedType = (int)(room.grandiosity / 0.125);

        if (bedType < 3)
        {
            bedType = 0;
        }
        else
        {
            bedType -= 2;
        }
        if (bedType > 8)
        {
            bedType = 8;
        }
        if (room.inhabitants.Count > 1 && bedType >= 7)
        {
            bedType = 6;
        }
        bedType++;
        return(bedType);
    }
Beispiel #7
0
 public AssignedRoom Create(AssignedRoom entity)
 {
     this.context.AssignedRooms.Add(entity);
     this.context.SaveChanges();
     return(entity);
 }
Beispiel #8
0
        /// <summary>
        /// An event that's called everytime the HotelEventManager pushes out an HotelEvent.
        /// </summary>
        /// <param name="Event">The HotelEvent containing event information.</param>
        public void Notify(HotelEvent Event)
        {
            //If the Customer is currently Evacuating they shouldn't listen to any other Events
            if (Status != HotelEventType.EVACUATE)
            {
                //If the Customer needs to Evacuate
                if (Event.EventType == HotelEventType.EVACUATE)
                {
                    //The Customer's WaitingTime is set to 0 (they need to abandon all current tasks)
                    WaitingTime = 0;
                    //The Customer's Status is set to EVACUATE so other Events won't be triggered
                    Status = HotelEventType.EVACUATE;

                    //And they'll EVACUATE to the Reception
                    Destination = Hotel.Reception.Node;
                    Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);
                }
                //If the Customer needs to hit the gym
                else if (Event.EventType == HotelEventType.GOTO_FITNESS)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //The Customer's FitnessTime will be set to the one given inside the HotelEvent
                            FitnessTime = Data[1];

                            //The Customer's Destination is set to the nearest Gym
                            Destination = Graph.NearestFacility(Hotel.Floors[PositionY].Areas[PositionX].Node, EAreaType.Fitness);
                            Path        = Graph.QuickestRoute(Graph.SearchNode(Hotel.Floors[PositionY].Areas[PositionX]), Destination, true, true);

                            //The Customer's Status is set to GOTO_FITNESS
                            Status = HotelEventType.GOTO_FITNESS;
                        }
                    }
                }
                //If the Customer needs to check out
                else if (Event.EventType == HotelEventType.CHECK_OUT)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //If the Customer checks out, their Room will be Dirty and needs to be cleaned
                            AssignedRoom.Dirty();
                            //Their Room will be set to Avaiable (by saying that the Room doesn't have an owner)
                            AssignedRoom.RoomOwner = null;

                            //The Customer will go to the Reception (the Reception won't do anything with the Customer, they'll dissapear if they arrive)
                            Destination = Hotel.Reception.Node;
                            Path        = Graph.QuickestRoute(Graph.SearchNode(Hotel.Floors[PositionY].Areas[PositionX]), Destination, true, true);

                            //The Customer's Status is set to CHECK_OUT
                            Status = HotelEventType.CHECK_OUT;
                        }
                    }
                }
                //If the Customer wants to go to a Cinema to catch the new Shrek Movie
                else if (Event.EventType == HotelEventType.GOTO_CINEMA)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //The Customer will move to the nearest Cinema (relative to their Position)
                            Destination = Graph.NearestFacility(Hotel.Floors[PositionY].Areas[PositionX].Node, EAreaType.Cinema);
                            Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);

                            //The Customer's Status is set to GOTO_CINEMA
                            Status = HotelEventType.GOTO_CINEMA;
                        }
                    }
                }
                //If the Customer needs food
                else if (Event.EventType == HotelEventType.NEED_FOOD)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //The Customer will move to the nearest Cinema (relative to their Position)
                            Destination = Graph.NearestFacility(Hotel.Floors[PositionY].Areas[PositionX].Node, EAreaType.Restaurant);
                            Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);

                            //The Customer's Status is set to NEED_FOOD
                            Status = HotelEventType.NEED_FOOD;
                        }
                    }
                }
            }
        }