public ActionResult Edit(int id, ApartmentEditData modelData, ICollection<HttpPostedFileBase> fileUpload)
        {
            //find apartment .. original value
            var apartmentToUpdate = _unitOfWork.ApartmentRepository.GetById(id);

            if (ModelState.IsValid)
            {
                //map properties
                AutoMapper.Mapper.CreateMap<ApartmentEditData, Amenities>();
                var amenitiesDto = AutoMapper.Mapper.Map<Amenities>(modelData);

                AutoMapper.Mapper.CreateMap<ApartmentEditData, Description>();
                var descriptionDto = AutoMapper.Mapper.Map<Description>(modelData);

                AutoMapper.Mapper.CreateMap<ApartmentEditData, HouseRules>();
                var houseRulesDto = AutoMapper.Mapper.Map<HouseRules>(modelData);

                AutoMapper.Mapper.CreateMap<ApartmentEditData, Location>();
                var locationDto = AutoMapper.Mapper.Map<Location>(modelData);

                AutoMapper.Mapper.CreateMap<ApartmentEditData, Prices>();
                var pricessDto = AutoMapper.Mapper.Map<Prices>(modelData);

                AutoMapper.Mapper.CreateMap<ApartmentEditData, TheSpace>();
                var theSpaceDto = AutoMapper.Mapper.Map<TheSpace>(modelData);

                //change FilePaths data - update pictures

                //loop through FilePaths
                var alreadyExists = false;
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var uploadedFile = Request.Files[i];

                    if (uploadedFile != null && uploadedFile.ContentLength > 0)
                    {
                        var newFileName = Path.GetFileName(uploadedFile.FileName);

                        //newFileName already in Db
                        for (int j = 0; j < apartmentToUpdate.FilePaths.Count; j++)
                        {
                            //check if current file name == new file name
                            if (newFileName == apartmentToUpdate.FilePaths.ElementAt(j).FileName)
                            {
                                alreadyExists = true; //if true skip
                                continue;
                            }
                        }//end for

                        //if picture is not in "databas"
                        if (!alreadyExists)
                        {
                            var path = Path.Combine(Server.MapPath("~/images/"), newFileName ?? "null");
                            uploadedFile.SaveAs(path); //save uploaded file to drive

                            //create new FilePath obj
                            // add to apartmentToUpdate.FilePaths
                            apartmentToUpdate.FilePaths.Add(new FilePath
                            {
                                Apartment = apartmentToUpdate,
                               // ApartmentId = apartmentToUpdate.Id,
                                FileName = newFileName,
                                FileType = FileType.Photo
                            });
                        }//end if
                        alreadyExists = false;
                    }//end if
                }

                apartmentToUpdate.Amenities = amenitiesDto;
                //apartmentToUpdate.Amenities.Id = id;
                apartmentToUpdate.Description = descriptionDto;
               // apartmentToUpdate.Description.Id = id;
                apartmentToUpdate.HouseRules = houseRulesDto;
               // apartmentToUpdate.HouseRules.Id = id;
                apartmentToUpdate.Location = locationDto;
               // apartmentToUpdate.Location.Id = id;
                apartmentToUpdate.Prices = pricessDto;
              //  apartmentToUpdate.Prices.Id = id;
                apartmentToUpdate.TheSpace = theSpaceDto;
              //  apartmentToUpdate.TheSpace.Id = id;
                apartmentToUpdate.Name = modelData.Name;

                _unitOfWork.ApartmentRepository.Update(apartmentToUpdate);

                _unitOfWork.Save();

                return RedirectToAction("Index");
            }

            return View(modelData);
        }
        //end Create method
        // GET: Apartment/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            //get selected app from database
            Apartment apartment = _unitOfWork.ApartmentRepository.GetById(id);

            //map to apartmentCreateData object
            var apartmentCreateData = new ApartmentEditData();

            if (apartment != null)
            {
                // -- (src class, dest class)
                AutoMapper.Mapper.CreateMap<Amenities, ApartmentEditData>();
                AutoMapper.Mapper.CreateMap<Description, ApartmentEditData>();
                AutoMapper.Mapper.CreateMap<HouseRules, ApartmentEditData>();
                AutoMapper.Mapper.CreateMap<Location, ApartmentEditData>();
                AutoMapper.Mapper.CreateMap<Prices, ApartmentEditData>();
                AutoMapper.Mapper.CreateMap<TheSpace, ApartmentEditData>();
                AutoMapper.Mapper.CreateMap<FilePath, ApartmentCreateData>();
                AutoMapper.Mapper.CreateMap<Apartment, ApartmentEditData>();

                // map (from, to)
                Mapper.Map(apartment.Amenities, apartmentCreateData);
                Mapper.Map(apartment.Description, apartmentCreateData);
                Mapper.Map(apartment.HouseRules, apartmentCreateData);
                Mapper.Map(apartment.Location, apartmentCreateData);
                Mapper.Map(apartment.Prices, apartmentCreateData);
                Mapper.Map(apartment.TheSpace, apartmentCreateData);
                Mapper.Map(apartment, apartmentCreateData);

            }

            if (apartment == null)
            {
                return HttpNotFound();
            }

            //return to View
            return View(apartmentCreateData);
        }