public ApartmentComfortViewModel GetById(int id)
        {
            var apartmentComfort = apartmentComfortRep.GetById(id);

            return(new ApartmentComfortViewModel
            {
                Id = apartmentComfort.Id,
                Name = apartmentComfort.Name
            });
        }
Beispiel #2
0
        public bool Create(ApartmentCreateViewModel createVM, string userId, string userName, string folderName)
        {
            Apartment create = new Apartment();

            create.AvailableToGuestId = createVM.AvailableToGuestId;
            create.Description        = createVM.Description;
            create.Price             = createVM.Price;
            create.TypeOfHousingId   = createVM.TypeOfHousingId;
            create.Address           = createVM.Street + " " + createVM.StreetNumber;
            create.MaxNumberOfGuests = createVM.MaxNumberOfGuests;
            create.UserProfileId     = userId;

            if (createVM.FletNumber != null)
            {
                create.Address += "/" + createVM.FletNumber;
            }

            FillApartmentCountryAndCity(create, createVM.CityAndCountry);

            if (createVM.SelectedApartmentComfortsId != null)
            {
                for (int i = 0; i < createVM.SelectedApartmentComfortsId.Count; i++)
                {
                    create.ApartmentComforts.Add(apartmentComfortRep.GetById(Int32.Parse(createVM.SelectedApartmentComfortsId[i])));
                }
            }

            apartmentRep.Create(create);
            apartmentRep.SaveChanges();

            FillApartmentImages(createVM.images.Length, createVM.images, create.Id, userName, folderName);
            return(true);
        }