/// <summary>
        /// Checks whether a given start hour is allowed.
        /// </summary>
        public void IsStartAllowed()
        {
            switch (SelectedArangement)
            {
            case "Wedding":
            {
                if (!Wedding.IsStartAllowed((TimeSpan)SelectedStartTime))
                {
                    throw new Exception("Het geselcteerde arangement kan aleen een start uur hebben tussen 7u en 15u.");
                }
            }
            break;

            case "Nightlife":
            {
                if (!Nightlife.IsStartAllowed((TimeSpan)SelectedStartTime))
                {
                    throw new Exception("Het geselcteerde arangement kan aleen een start uur hebben tussen 7u en 15u.");
                }
            }
            break;

            case "Wellness":
            {
                if (!Wellness.IsStartAllowed((TimeSpan)SelectedStartTime))
                {
                    throw new Exception("Het geselcteerde arangement kan aleen een start uur hebben tussen 7u en 15u.");
                }
            }
            break;
            }
        }
Exemple #2
0
        public void TestWellnessGetHoursHourspanToShort()
        {
            Wellness wellness             = new Wellness(100);
            DateTime reservationDateStart = new DateTime(2020, 01, 23, 8, 00, 00);
            DateTime reservationDateEnd   = new DateTime(2020, 01, 23, 10, 00, 00);
            int      firstHourPrice       = 10;
            Action   act = () => wellness.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            act.ShouldThrow <ArgumentException>().Message.ShouldBe("Tijdsduur moet 10 uur lang zijn.");
        }
Exemple #3
0
        public void TestWellnessGetHoursStartDateToBig()
        {
            Wellness wellness             = new Wellness(100);
            DateTime reservationDateStart = new DateTime(2020, 01, 23, 13, 00, 00);
            DateTime reservationDateEnd   = new DateTime(2020, 01, 23, 23, 00, 00);
            int      firstHourPrice       = 10;
            Action   act = () => wellness.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            act.ShouldThrow <ArgumentException>().Message.ShouldBe("Startreservatie moet tussen 7 uur en 12 uur zitten.");
        }
Exemple #4
0
        public void TestWellnessGetHoursStartDateInRange()
        {
            Wellness wellness             = new Wellness(100);
            DateTime reservationDateStart = new DateTime(2020, 01, 23, 11, 00, 00);
            DateTime reservationDateEnd   = new DateTime(2020, 01, 23, 21, 00, 00);
            int      firstHourPrice       = 10;
            Action   act = () => wellness.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            act.ShouldNotThrow();
        }
Exemple #5
0
        public void WellnessTest_Methods()
        {
            Wellness wellness  = new Wellness(1000);
            TimeSpan StartHour = new TimeSpan(10, 0, 0);
            TimeSpan EndHour   = new TimeSpan(20, 0, 0);

            wellness.SetTime(new TimeSpan(10, 0, 0));
            wellness.StartHour.Should().Be(StartHour);
            wellness.EndHour.Should().Be(EndHour);
            wellness.GetEndTime();
        }
Exemple #6
0
        public void TestWellnessGetHoursReturnsCorrectHours()
        {
            Wellness    wellness             = new Wellness(100);
            DateTime    reservationDateStart = new DateTime(2020, 01, 23, 8, 00, 00);
            DateTime    reservationDateEnd   = new DateTime(2020, 01, 23, 18, 00, 00);
            int         firstHourPrice       = 10;
            List <Hour> hoursTest            = wellness.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            hoursTest[0].Period.ShouldBe(10);
            hoursTest[0].UnitPrice.ShouldBe(100);
        }
Exemple #7
0
        public ActionResult WellnessCreate(FormCollection frm)
        {
            Wellness tbl = new Wellness();

            tbl.Title       = frm["Title"];
            tbl.Duration    = frm["Duration"];
            tbl.Description = frm["Description"];
            tbl.WVideoLink  = frm["VideoLink"];
            db.Wellnesses.Add(tbl);
            db.SaveChanges();
            return(View());
        }
Exemple #8
0
        public void TestWellnessGetHoursInvalidValuePrice()
        {
            //Arrange = initialisatie obejcten/methodes
            Wellness wellness             = new Wellness(null);
            DateTime reservationDateStart = new DateTime(2020, 01, 23, 7, 00, 00);
            DateTime reservationDateEnd   = new DateTime(2020, 01, 23, 17, 00, 00);
            int      firstHourPrice       = 10;
            //Act roept test methode op met ingestelde parameters
            Action act = () => wellness.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            //Assert verifieert of juist
            act.ShouldThrow <InvalidOperationException>().Message.ShouldBe("Arrangement niet beschikbaar");
        }
        public async Task <ActionResult <Wellness> > CreateWellnessByUser(Wellness wellness)
        {
            if (wellness.Id != 0)
            {
                _context.Entry(wellness).State = EntityState.Modified;
            }
            else
            {
                _context.Wellness.Add(wellness);
            }
            await _context.SaveChangesAsync();

            return(wellness);
        }
        public async void saveWelness()
        {
            Wellness well = new Wellness();

            well.user_id = 1;
            well.sleep   = SleepHours;
            well.mood    = SelectedMood;
            if (well.mood == null)
            {
                well.mood = "";
            }
            well.date = DateTime.Now;



            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://ihbiproject.azurewebsites.net/api/Welnesses"));

            request.ContentType = "application/json";
            request.Method      = "POST";
            using (Stream sendStream = await request.GetRequestStreamAsync())
            {
                using (StreamWriter sw = new StreamWriter(sendStream))
                {
                    JsonSerializer jsOut = new JsonSerializer();
                    jsOut.NullValueHandling = NullValueHandling.Ignore;
                    jsOut.Serialize(sw, well);
                }
            }

            using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    System.Diagnostics.Debug.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusDescription);
                }
                else
                {
                    using (Stream stream = response.GetResponseStream()) {
                        using (StreamReader reader = new StreamReader(stream)) {
                            //String result = reader.ReadToEnd ();
                            JsonSerializer serializer = new JsonSerializer();
                            Wellness       result     = (Wellness)serializer.Deserialize(reader, typeof(Wellness));
                            System.Diagnostics.Debug.WriteLine("===> Users: " + result.ToString());
                        }
                    }
                }
            }
        }
Exemple #11
0
        public void WellnessTest_Exceptions()
        {
            Wellness wellness = new Wellness(1000);
            Action   act      = () => wellness.SetTime(new TimeSpan(10, 1, 0));

            act.Should().Throw <DomainException>().WithMessage("Zorg er a.u.b. voor dat het start uur geen minuten of seconden heeft.");

            act = () => wellness.SetTime(new TimeSpan(10, 0, 1));
            act.Should().Throw <DomainException>().WithMessage("Zorg er a.u.b. voor dat het start uur geen minuten of seconden heeft.");

            act = () => wellness.SetTime(new TimeSpan(6, 0, 0));
            act.Should().Throw <DomainException>().WithMessage("Het arangement wellness kan aleen tussen 7 en 12 uur in de ochtend geboekt worden.");

            act = () => wellness.SetTime(new TimeSpan(13, 0, 0));
            act.Should().Throw <DomainException>().WithMessage("Het arangement wellness kan aleen tussen 7 en 12 uur in de ochtend geboekt worden.");
        }
Exemple #12
0
        public void WellnessTest_Constructor()
        {
            int      Price      = 1000;
            TimeSpan StartHour  = new TimeSpan(40, 0, 0);
            TimeSpan EndHour    = new TimeSpan(40, 0, 0);
            long     StartTicks = 1440000000000;
            long     EndTicks   = 1440000000000;

            Wellness wellness = new Wellness(1000);

            wellness.Price.Should().Be(Price);
            wellness.StartHour.Should().Be(StartHour);
            wellness.EndHour.Should().Be(EndHour);
            wellness.StartHourTicks.Should().Be(StartTicks);
            wellness.EndHourTicks.Should().Be(EndTicks);
        }
        public async Task <ActionResult <Wellness> > CreateUpdateWellnessByUserId([FromBody] Wellness wellness)
        {
            try
            {
                var createdWellness = await _wellnessService.CreateWellnessByUser(wellness);

                if (createdWellness is null)
                {
                    return(NotFound());
                }
                return(Ok(createdWellness));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
		public async void saveWelness() 
		{
			Wellness well = new Wellness ();
			well.user_id = 1;
			well.sleep = SleepHours;
			well.mood = SelectedMood;
            if (well.mood == null)
                well.mood = "";
			well.date = DateTime.Now;



			HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create (new Uri ("http://ihbiproject.azurewebsites.net/api/Welnesses"));
			request.ContentType = "application/json";
			request.Method = "POST";
			using (Stream sendStream = await request.GetRequestStreamAsync ()) 
			{
				using (StreamWriter sw = new StreamWriter (sendStream)) 
				{
					JsonSerializer jsOut = new JsonSerializer ();
					jsOut.NullValueHandling = NullValueHandling.Ignore;
					jsOut.Serialize (sw, well);
				}
			}

			using (HttpWebResponse response = (HttpWebResponse) await request.GetResponseAsync())
			{
				if (response.StatusCode != HttpStatusCode.OK) {
					System.Diagnostics.Debug.WriteLine ("Error fetching data. Server returned status code: {0}", response.StatusDescription);
				} else {
					using (Stream stream = response.GetResponseStream ()) {

						using (StreamReader reader = new StreamReader (stream)) {
							//String result = reader.ReadToEnd ();
							JsonSerializer serializer = new JsonSerializer ();
							Wellness result = (Wellness)serializer.Deserialize (reader, typeof(Wellness));
							System.Diagnostics.Debug.WriteLine ("===> Users: " + result.ToString ());
						}

					}
				}
			}

		}
        private static void Wellnesssearchesults(BrowserSession browser, HtmlNode resulttable, string searchkey, ApportiswebscrapperContext db)
        {
            resulttable = resulttable.SelectSingleNode("//table[@class='ep_searchResultTable']");
            //throw new NotImplementedException();
            var doc = new HtmlDocument();

            doc.LoadHtml(resulttable.InnerHtml);
            var listoflinks = doc.DocumentNode.SelectNodes("//a[@href]");
            int count       = 0;

            foreach (var row in listoflinks)
            {
                if (count == 3)
                {
                    break;
                }

                Wellness obj = new Wellness();
                count++;
                var      href           = row.Attributes["href"].Value;
                HtmlNode DataPageResult = browser.Get((HttpUtility.HtmlDecode(href)));

                var doc2 = new HtmlDocument();
                doc2.LoadHtml(DataPageResult.InnerHtml);
                var innernode = doc2.DocumentNode.SelectSingleNode("//div[@id='ep_documentBody']");
                if (innernode != null)
                {
                    obj.ep_documentBody = innernode.InnerText;
                    obj.Articleno       = count;
                    obj.searchkey       = searchkey;
                }
                try
                {
                    db.Wellnesses.Add(obj);
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    throw ex;
                }
                var x = 80;
                //  Printthedata(innernode);
            }
        }
Exemple #16
0
        private static List <Limousine> ReadLimousines(List <string[]> file)
        {
            List <Limousine> limos = new List <Limousine>();

            foreach (string[] line in file.Skip(1))
            {
                string             name           = line[0]; //try catch ??
                int                firstHourPrice = int.Parse(line[1]);
                NightLife          nightLife      = new NightLife(parseToNullableInt(line[2]));
                Wedding            wedding        = new Wedding(parseToNullableInt(line[3]));
                Wellness           wellness       = new Wellness(parseToNullableInt(line[4]));
                List <Arrangement> arrangements   = new List <Arrangement>()
                {
                    nightLife, wedding, wellness
                };
                Limousine limo = new Limousine(name, firstHourPrice, arrangements);
                limos.Add(limo);
                Console.WriteLine($"added limo: {limo.Name}");
            }
            return(limos);
        }