public SubscriptionModel MapData(Subscription s)
        {
            SubscriptionModel model = new SubscriptionModel();

            model.Id = s.Id;
            model.UserId = s.UserId;
            model.VacId = s.VacationId;
            model.FirstName = s.FirstName;
            model.LastName = s.LastName;
            model.RNR = s.RNR;
            model.Street = s.Street;
            model.HouseNr = s.HouseNr;
            model.PostalCode = s.PostalCode;
            model.City = s.City;
            model.Name_Mother = s.Name_Mother;
            model.Name_Father = s.Name_Father;
            model.RNR_Mother = s.RNR_Mother;
            model.RNR_Father = s.RNR_Father;
            model.TelephoneNumber = s.TelephoneNumber;
            model.Email = s.Email;
            model.Payed = s.Payed;
            model.FacturationAddress = s.FacturationAddress;
            model.FacturationName = s.FacturationName;

            return model;
        }
        public Subscription MapData(SubscriptionModel sm)
        {
            Subscription s = new Subscription();

            s.Id = sm.Id;
            s.VacationId = sm.VacId;
            s.UserId = sm.UserId;
            s.FirstName = sm.FirstName;
            s.LastName = sm.LastName;
            s.RNR = sm.RNR;
            s.Street = sm.Street;
            s.HouseNr = sm.HouseNr;
            s.PostalCode = sm.PostalCode;
            s.City = sm.City;
            s.Name_Mother = sm.Name_Mother;
            s.Name_Father = sm.Name_Father;
            s.RNR_Mother = sm.RNR_Mother;
            s.RNR_Father = sm.RNR_Father;
            s.TelephoneNumber = sm.TelephoneNumber;
            s.Email = sm.Email;
            s.Payed = sm.Payed;
            s.FacturationAddress = sm.FacturationAddress;
            s.FacturationName = sm.FacturationName;

            return s;
        }
        public HttpResponseMessage PostSubscribe(SubscriptionModel model)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            if (!ModelState.IsValid)
            {
                var b = BadRequest(ModelState);
            }

            int VacId = model.VacId;
            int UserId = model.UserId;

            Vacation wantedVacation = _db.Vacations.Find(VacId);
            int subscriptionsAmount = _db.Subscriptions.Where(s => s.VacationId == VacId).Count();
            if ((wantedVacation.NumberOfParticipants - subscriptionsAmount) > 1)
            {
                bool ValidSubscription = true;
                List<Subscription> subscriptions = _db.Subscriptions.Where(s => s.UserId == UserId).ToList();
                if (subscriptions.Count > 0)
                {
                    foreach (Subscription s in subscriptions)
                    {
                        Vacation ListedVacation = _db.Vacations.Find(s.VacationId);
                        Period period = ListedVacation.When;
                        //CompareTo:
                        //A signed number indicating the relative values of this instance and the value
                        //parameter.Value Description Less than zero This instance is earlier than
                        //value. Zero This instance is the same as value. Greater than zero This instance
                        //is later than value.

                        //if the starting and ending date of the listed vacation do not lie in between the starting and ending date of the vacation with a pending subscription
                        // wantedVacation.When.DateStart <= period.DateStart <= twantedVacation.When.DateEnd
                        if((((period.DateStart.CompareTo(wantedVacation.When.DateEnd) <= 0) && (period.DateStart.CompareTo(wantedVacation.When.DateStart) >= 1))
                            // wantedVacation.When.DateStart <= period.DateEnd <= twantedVacation.When.DateEnd
                            || ((period.DateEnd.CompareTo(wantedVacation.When.DateEnd) <= 0) && (period.DateEnd.CompareTo(wantedVacation.When.DateStart) >= 1))))
                            {

                                ValidSubscription = false;
                            }
                        if (model.RNR.Equals(s.RNR))
                        {
                            ValidSubscription = false;
                        }
                    }
                    if (ValidSubscription)
                    {
                        _db.Subscriptions.Add(new SubscriptionMTEAdapter().MapData(model));
                        _db.SaveChanges();
                        response.StatusCode = HttpStatusCode.OK;
                    }
                    else
                    {
                        response.StatusCode = HttpStatusCode.NotAcceptable;
                    }
                }
                else
                {
                    _db.Subscriptions.Add(new SubscriptionMTEAdapter().MapData(model));
                    _db.SaveChanges();
                    response.StatusCode = HttpStatusCode.OK;
                }
            }
            else
            {
                response.StatusCode = HttpStatusCode.NotAcceptable;
            }

            return response;
        }