public VacationModel MapData(Aug2015Backend.Entities.Vacation v)
        {
            VacationModel mappedVacation = new VacationModel();

            if (v != null)
            {
                mappedVacation.Pictures = pictureAdapter.MapData(v.Picture);
                mappedVacation.Cover = pictureAdapter.MapData(v.Cover);
                mappedVacation.PromoText = v.PromoText;
                mappedVacation.ContactInformation = contactInformationAdapter.MapData(v.ContactInformation);
                mappedVacation.Included = itemAdapter.MapData(v.Included);
                mappedVacation.Cost = priceAdapter.MapData(v.Cost);
                mappedVacation.NumberOfParticipants = v.NumberOfParticipants;
                mappedVacation.Location = locationAdapter.MapData(v.Location);
                mappedVacation.When = periodAdapter.MapData(v.When);
                ICollection<CommentModel> comments = commentAdapter.MapData(v.Comment);
                mappedVacation.Comment = comments;
                mappedVacation.Leeftijd = arAdapter.MapData(v.AgeRange);
                mappedVacation.Titel = v.Titel;
                mappedVacation.Id = v.Id;
                mappedVacation.Tax_Benefit = v.Tax_Benefit;
            }

            return mappedVacation;
        }
        public Vacation MapData(VacationModel v)
        {
            Vacation mappedVacation = new Vacation();

            if (v != null)
            {
                if (v.Cover != null)
                {
                    mappedVacation.Cover = pictureAdapter.MapData(v.Cover);
                }
                mappedVacation.PromoText = v.PromoText;
                mappedVacation.ContactInformation = contactInformationAdapter.MapData(v.ContactInformation, v.Id);
                mappedVacation.Included = itemAdapter.MapData(v.Included);
                mappedVacation.Cost = priceAdapter.MapData(v.Cost, v.Id);
                mappedVacation.NumberOfParticipants = v.NumberOfParticipants;
                mappedVacation.When = periodAdapter.MapData(v.When, v.Id);
                mappedVacation.Location = locationAdapter.MapData(v.Location);
                mappedVacation.Comment = commentAdapter.MapData(v.Comment, v.Id);
                mappedVacation.AgeRange = arAdapter.MapData(v.Leeftijd, v.Id);
                mappedVacation.Titel = v.Titel;
                mappedVacation.Id = v.Id;
                mappedVacation.Tax_Benefit = v.Tax_Benefit;
            }

            return mappedVacation;
        }
        public int PutVacation(VacationModel vacModel)
        {
            var original = _db.Vacations.Find(vacModel.Id);

            if (original != null)
            {
                original.Titel = vacModel.Titel;

                UpdateAgeRange(vacModel.Leeftijd);

                var originalLocation = original.Location;
                _db.Entry(originalLocation).CurrentValues.SetValues(new LocationMTEAdapter().MapData(vacModel.Location));

                original.NumberOfParticipants = vacModel.NumberOfParticipants;

                var originalCost = original.Cost;
                _db.Entry(originalCost).CurrentValues.SetValues(new PriceMTEAdapter().MapData(vacModel.Cost, vacModel.Id));

                var originalPeriod = original.When;
                _db.Entry(originalPeriod).CurrentValues.SetValues(new PeriodMTEAdapter().MapData(vacModel.When, vacModel.Id));

                foreach (IncludedItem i in original.Included.ToList())
                {
                    _db.Entry(i).State = EntityState.Deleted;
                }

                original.Included = new IncludedItemMTEAdapter().MapData(vacModel.Included);

                var originalContactInformation = original.ContactInformation;
                _db.Entry(originalContactInformation).CurrentValues.SetValues(new ContactInformationMTEAdapter().MapData(vacModel.ContactInformation, vacModel.Id));

                foreach (Comment c in original.Comment.ToList())
                {
                    _db.Entry(c).State = EntityState.Deleted;
                }

                foreach (CommentModel cm in vacModel.Comment.ToList())
                {
                    _db.Comment.Add(new CommentMTEAdapter().MapData(cm, vacModel.Id));
                }
                original.PromoText = vacModel.PromoText;

                foreach (Picture p in original.Picture)
                {
                    foreach (PictureModel pm in vacModel.Pictures)
                    {
                        if (p.Id == pm.Id)
                            _db.Entry(p).CurrentValues.SetValues(new PictureMTEAdapter().MapData(pm));
                    }
                }
                var originalCover = original.Cover;
               // _db.Entry(originalCover).CurrentValues.SetValues(new PictureMTEAdapter().MapData(vacModel.Cover));
                if (original.Cover != null)
                {
                    original.Cover = new PictureMTEAdapter().MapData(vacModel.Cover);
                }
                original.Tax_Benefit = vacModel.Tax_Benefit;
                try
                {
                    _db.SaveChanges();
                }
                catch (Exception e)
                {
                    var b = true;
                }
            }
            return original.Id;
        }
        public int PostVacation(VacationModel vacModel)
        {
            List<Vacation> vacations = _db.Vacations.ToList();

            List<int> ids = new List<int>();
            foreach (Vacation v in vacations)
            {
                ids.Add(v.Id);
            }

            int max = 0;
            if (ids.Count() > 0)
            {
                max = ids.Max();
            }

            vacModel.Id = max + 1;
            Vacation vac = _vacToEntityAdapter.MapData(vacModel);
            _db.Vacations.Add(vac);
            try
            {
                _db.SaveChanges();
            }
            catch (Exception e)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            return vacModel.Id;
        }