Наследование: INotifyPropertyChanging, INotifyPropertyChanged
Пример #1
0
        public Reply Save([FromBody] Models.Requests.Room room)
        {
            Reply reply = new Reply();

            try
            {
                using (ChatPruebaTecnicaDBEntities db = new ChatPruebaTecnicaDBEntities())
                {
                    Models.Room modelRoom = new Models.Room
                    {
                        name         = room.Name,
                        description  = room.Description,
                        date_created = DateTime.Now,
                        idState      = 1
                    };

                    db.Rooms.Add(modelRoom);
                    reply.Result = db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                reply.Result  = 0;
                reply.Message = "Intentalo más tarde.";
                reply.Data    = e.InnerException;
            }

            return(reply);
        }
Пример #2
0
        public void Seed(DiagnoseMeDbContext context)
        {
            if(!context.Rooms.Any())
            {
                var generator = new Random();
                var users = context.Users.ToList();

                for (int i = 1; i <= 36; i++)
                {
                    var creator = users[generator.Next(0, users.Count)];

                    var room = new Room()
                    {
                        Context = Guid.NewGuid(),
                        Name = "Room " + i,
                        CreatorId = creator.Id
                    };

                    creator.Rooms.Add(room);
                    context.Users.AddOrUpdate(creator);
                }

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Adds a new room to the venue with the specified ID.
        /// </summary>
        /// <param name="venueId">Venue id.</param>
        /// <param name="places">Places.</param>
        /// <param name="pricePerDay">The price per day.</param>
        /// <returns>New view.</returns>
        public IView Add(int venueId, int places, decimal pricePerDay)
        {
            this.Authorize(Roles.VenueAdmin);
            var venue = this.Data.RepositoryWithVenues.Get(venueId);
            if (venue == null)
            {
                return this.NotFound(string.Format("The venue with ID {0} does not exist.", venueId));
            }

            var newRoom = new Room(places, pricePerDay);
            venue.Rooms.Add(newRoom);
            this.Data.RepositoryWithRooms.Add(newRoom);
            return this.View(newRoom);
        }
Пример #4
0
        private IView Add(int venueId, int places, decimal pricePerDay)
        {
            this.Authorize(Roles.VenueAdmin);
            var venue = Data.RepositoryWithVenues.Get(venueId);
            if (venue != null)
            {
                return this.NotFound($"The venue with ID {venueId} does not exist.");
            }

            var newRoom = new Room(places, pricePerDay);
            venue.Rooms.Add(newRoom);
            Data.RepositoryWithRooms.Add(newRoom);
            return this.View(newRoom);
        }
        private void UpdateRoomAvailability(DateTime startDate, DateTime endDate, Room room, AvailableDate availablePeriod)
        {
            room.AvailableDates.Remove(availablePeriod);
            var periodBeforeBooking = startDate - availablePeriod.StartDate;
            if (periodBeforeBooking > TimeSpan.Zero)
            {
                room.AvailableDates.Add(new AvailableDate(availablePeriod.StartDate, availablePeriod.StartDate.Add(periodBeforeBooking)));
            }

            var periodAfterBooking = availablePeriod.EndDate - endDate;
            if (periodAfterBooking > TimeSpan.Zero)
            {
                room.AvailableDates.Add(new AvailableDate(availablePeriod.EndDate.Subtract(periodAfterBooking), availablePeriod.EndDate));
            }
        }
Пример #6
0
        // BUG: parameter is passed as string, should be parsed to decimal
        /// <summary>
        /// Adds new room to a specified venue.
        /// </summary>
        /// <param name="venueId">Id of the venue.</param>
        /// <param name="places">Places in the room.</param>
        /// <param name="pricePerDay">Price for stay in the room per day.</param>
        /// <returns>IView containing the result of the action.</returns>
        public IView Add(int venueId, int places, string pricePerDay)
        {
            decimal pricePerDayDecimal = decimal.Parse(pricePerDay);
            this.Authorize(Roles.VenueAdmin);
            var venue = this.Data.RepositoryWithVenues.Get(venueId);

            // BUG: boolean statement inverted
            if (venue == null)
            {
                return this.NotFound(string.Format("The venue with ID {0} does not exist.", venueId));
            }

            var newRoom = new Room(places, pricePerDayDecimal);
            venue.Rooms.Add(newRoom);
            this.Data.RepositoryWithRooms.Add(newRoom);
            return this.View(newRoom);
        }
        /// <summary>
        /// Adds a new room to the venue with the specified ID.
        /// </summary>
        /// <param name="venueId">id of the venue</param>
        /// <param name="places">how much places does the room have</param>
        /// <param name="pricePerDay"></param>
        /// <returns></returns>
        public IView Add(int venueId, int places, decimal pricePerDay)
        {
            this.Authorize(Roles.VenueAdmin);

            var venue = Data.Venues.GetElementById(venueId);

            if (venue == null)
            {
                throw new ArgumentException(string.Format("The venue with ID {0} does not exist.", venueId));
            }

            var newRoom = new Room(places, pricePerDay);

            venue.Rooms.Add(newRoom);
            this.Data.Rooms.Add(newRoom);

            return this.View(newRoom);
        }
        /// <summary>
        /// Adds a new room to venue by given venue id,
        /// places and price per day.
        /// </summary>
        /// <param name="venueId">The id of venue</param>
        /// <param name="places">Number of places</param>
        /// <param name="pricePerDay">Price per day for the room</param>
        /// <returns>A view in case of success of error message, if venue with
        /// the given id was not found.</returns>
        public IView Add(int venueId, int places, decimal pricePerDay)
        {
            this.Authorize(Roles.VenueAdmin);
            var venue = this.Data.VenuesRepository.Get(venueId);

            if (venue == null)
            {
                return this.NotFound(string.Format(Constants.VenueWithIdNotExistMsg, venueId));
            }

            var newRoom = new Room(places, pricePerDay);

            venue.Rooms.Add(newRoom);

            this.Data.RoomsRepository.Add(newRoom);

            return this.View(newRoom);
        }
        public async static Task<RoomGeometryViewModel> CreateFromRoom(Room room)
        {
            Data data = new Data();

            double[] projectedEdgeHeights = room.Edges.Select(e => e.ProjectedHeight).ToArray();
            double focalDistance = await data.GetFoucsDistance();

            List<double> distances = Measurer.GetEdgeDistances(
                projectedEdgeHeights,
                focalDistance,
                room.ProjectedReferenceHeight,
                room.ActualReferenceHeight);

            List<double> orientations = room.Edges.Select(e => e.ZRotation).ToList();

            List<double> actualWallSizes = Measurer.GetActualWallSizes(distances, orientations);

            RoomGeometryViewModel roomGeometry = new RoomGeometryViewModel(distances, orientations, actualWallSizes);

            return roomGeometry;
        }
Пример #10
0
 partial void InsertRoom(Room instance);
Пример #11
0
		private void detach_Rooms(Room entity)
		{
			this.SendPropertyChanging();
			entity.Event = null;
		}
Пример #12
0
		private void attach_Rooms(Room entity)
		{
			this.SendPropertyChanging();
			entity.Event = this;
		}
Пример #13
0
 public AddPeriod(Room room)
     : base(room)
 {
 }
        public void CalculateHeight(Room room)
        {
            this.Edge = room.Edges.Last();

            this.CalculatedHeight = Measurer.GetRealHeight(this.Edge.ProjectedHeight, room.ProjectedReferenceHeight, room.ActualReferenceHeight);
        }
Пример #15
0
 public Add(Room room)
     : base(room)
 {
 }
Пример #16
0
 partial void UpdateRoom(Room instance);
Пример #17
0
 partial void DeleteRoom(Room instance);
 private void ExecuteSelectedItemCommand(Room obj)
 {
     this.NavigationService.Navigate(typeof(RoomDetailsPage), obj);
 }