public IHttpActionResult PostOpeningHour(OpeningHour openingHour)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.OpeningHours.Add(openingHour);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (OpeningHourExists(openingHour.Destination_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = openingHour.Destination_ID }, openingHour));
        }
Ejemplo n.º 2
0
        public void DeleteOpeningHourValidInput()
        {
            var openingHours = context.GetAllOpeningHoursType();

            Assert.AreEqual(6, openingHours.Count());

            //hebrew
            var openingHourResultsHeb = context.GetAllOpeningHours((int)Languages.he);

            Assert.AreEqual(6, openingHourResultsHeb.Count());

            //english
            var openingHourResultsEn = context.GetAllOpeningHours((int)Languages.en);

            Assert.AreEqual(6, openingHourResultsEn.Count());

            OpeningHour opHour = openingHours.SingleOrDefault(oh => oh.day == 1);

            context.DeleteOpeningHour(opHour.id);

            openingHours = context.GetAllOpeningHoursType();
            Assert.AreEqual(5, openingHours.Count());

            //hebrew
            openingHourResultsHeb = context.GetAllOpeningHours((int)Languages.he);
            Assert.AreEqual(5, openingHourResultsHeb.Count());
            Assert.IsFalse(openingHourResultsHeb.Any(oh => oh.Day == "ראשון"));

            //english
            openingHourResultsEn = context.GetAllOpeningHours((int)Languages.en);
            Assert.AreEqual(5, openingHourResultsEn.Count());
            Assert.IsFalse(openingHourResultsEn.Any(oh => oh.Day == "Sunday"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks and sets the service hours for out api.
        /// </summary>
        public void CheckServiceHour()
        {
            var hourType = ServiceHoursTypeEnum.Standard;

            Enum.TryParse(ServiceHourType, out hourType);
            switch (hourType)
            {
            case ServiceHoursTypeEnum.Standard:
                // If ValidTo field is null opening hour is valid for now
                if (!ValidTo.HasValue)
                {
                    ValidFrom   = null;
                    ValidForNow = true;
                }
                // Set DayTo as empty. In db DayTo is always 'Monday' - not very logical for end user since the time is supposed to be valid on this certain week day. PTV-3455
                OpeningHour.ForEach(h => { h.DayTo = ""; });
                break;

            case ServiceHoursTypeEnum.Exception:
                // Set DayFrom and DayTo fields as null - in database these fields are not set correctly!
                OpeningHour.ForEach(h => { h.DayFrom = null; h.DayTo = null; });
                break;

            case ServiceHoursTypeEnum.Special:
                // If ValidTo field is null opening hour is valid for now
                if (!ValidTo.HasValue)
                {
                    ValidFrom   = null;
                    ValidForNow = true;
                }
                break;
            }
        }
        public IHttpActionResult PutOpeningHour(long id, OpeningHour openingHour)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != openingHour.Destination_ID)
            {
                return(BadRequest());
            }

            db.Entry(openingHour).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OpeningHourExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 5
0
        public void DeleteOpeningHourValidInput()
        {
            var openingHours = ZooInfoController.GetAllOpeningHoursType();

            Assert.AreEqual(6, openingHours.Count());

            //hebrew
            var openingHourResultsHeb = ZooInfoController.GetAllOpeningHourResults(1);

            Assert.AreEqual(6, openingHourResultsHeb.Count());

            //english
            var openingHourResultsEn = ZooInfoController.GetAllOpeningHourResults(2);

            Assert.AreEqual(6, openingHourResultsEn.Count());

            OpeningHour opHour = openingHours.SingleOrDefault(oh => oh.day == 1);

            ZooInfoController.DeleteOpeningHour(opHour.id);

            openingHours = ZooInfoController.GetAllOpeningHoursType();
            Assert.AreEqual(5, openingHours.Count());

            //hebrew
            openingHourResultsHeb = ZooInfoController.GetAllOpeningHourResults(1);
            Assert.AreEqual(5, openingHourResultsHeb.Count());
            Assert.IsFalse(openingHourResultsHeb.Any(oh => oh.Day == "ראשון"));

            //english
            openingHourResultsEn = ZooInfoController.GetAllOpeningHourResults(2);
            Assert.AreEqual(5, openingHourResultsEn.Count());
            Assert.IsFalse(openingHourResultsEn.Any(oh => oh.Day == "Sunday"));
        }
Ejemplo n.º 6
0
        public void UpdateOpeningHour(OpeningHour openingHour)
        {
            try
            {
                using (var db = GetContext())
                {
                    if (ValidateSessionId(db))
                    {
                        db.UpdateOpeningHour(openingHour);
                    }
                    else
                    {
                        throw new AuthenticationException("Couldn't validate the session");
                    }
                }
            }
            catch (Exception Exp)
            {
                var openingInput = "Id: " + openingHour.id + ", day: " + openingHour.day +
                                   ", start time: " + openingHour.startTime + ", end time: " + openingHour.endTime +
                                   ", language: " + openingHour.language;

                Logger.GetInstance(isTesting).WriteLine(Exp.Message, Exp.StackTrace, "Opening Hour: " + openingInput);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 7
0
 //From DAL to DTO
 public OpeningHourDTO(OpeningHour o)
 {
     this.branchId = o.branchId;
     this.fromDay  = o.fromDay;
     this.toDay    = o.toDay;
     this.fromHour = o.fromHour;
     this.toHour   = o.toHour;
 }
Ejemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            OpeningHour openingHour = db.OpeningHours.Find(id);

            db.OpeningHours.Remove(openingHour);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //public bool RemoveOngoingBooking(int id)
        //{
        //    Model.OngoingBookings.Remove(Model.OngoingBookings.Find(id));
        //    return SaveChangesToDB();
        //}
        public bool UpdateOpeningHours(int id, OpeningHour openingHour)
        {
            var opHour = Model.OpeningHours.Find(id);

            opHour.OpeningTime = openingHour.OpeningTime;
            opHour.ClosingTime = openingHour.ClosingTime;

            return(SaveChangesToDB());
        }
Ejemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Id,Day,OpenHour,OrderBy")] OpeningHour openingHour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(openingHour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(openingHour));
 }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "Id,Day,OpenHour,OrderBy")] OpeningHour openingHour)
        {
            if (ModelState.IsValid)
            {
                db.OpeningHours.Add(openingHour);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(openingHour));
        }
        public IHttpActionResult GetOpeningHour(long id)
        {
            OpeningHour openingHour = db.OpeningHours.Find(id);

            if (openingHour == null)
            {
                return(NotFound());
            }

            return(Ok(openingHour));
        }
Ejemplo n.º 13
0
        public void UpdateOpeningHour()
        {
            var openingHours = context.GetAllOpeningHoursType();

            Assert.AreEqual(6, openingHours.Count());
            Assert.IsTrue(openingHours.Any(oh => oh.day == 1));

            var openingHourResultHeb = context.GetAllOpeningHours((int)Languages.he);

            Assert.IsTrue(openingHourResultHeb.Any(oh => oh.Day == "שבת"));

            var openingHourResultEn = context.GetAllOpeningHours((int)Languages.en);

            Assert.IsTrue(openingHourResultEn.Any(oh => oh.Day == "Saturday"));

            OpeningHour opHour = new OpeningHour
            {
                id        = 11,
                day       = 7,
                startTime = new TimeSpan(10, 45, 0),
                endTime   = new TimeSpan(18, 0, 0),
                language  = (int)Languages.he
            };

            var newTime = new TimeSpan(20, 0, 0);

            opHour.endTime = newTime;

            context.UpdateOpeningHour(opHour);

            openingHours = context.GetAllOpeningHoursType();

            opHour = openingHours.SingleOrDefault(oh => oh.day == 7);
            Assert.IsNotNull(opHour);
            Assert.AreEqual(newTime, opHour.endTime);

            //heb
            openingHourResultHeb = context.GetAllOpeningHours((int)Languages.he);
            Assert.AreEqual(6, openingHourResultHeb.Count());
            var fridayHeb = openingHourResultHeb.SingleOrDefault(oh => oh.Day == "שבת");

            Assert.IsNotNull(fridayHeb);
            Assert.AreEqual(newTime, fridayHeb.EndTime);

            openingHourResultEn = context.GetAllOpeningHours((int)Languages.en);
            Assert.AreEqual(6, openingHourResultEn.Count());
            var fridayEn = (openingHourResultEn.SingleOrDefault(oh => oh.Day == "Saturday"));

            Assert.IsNotNull(fridayEn);
            Assert.AreEqual(newTime, fridayEn.EndTime);
        }
Ejemplo n.º 14
0
        // GET: Manage/OpeningHours/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OpeningHour openingHour = db.OpeningHours.Find(id);

            if (openingHour == null)
            {
                return(HttpNotFound());
            }
            return(View(openingHour));
        }
        public IHttpActionResult DeleteOpeningHour(long id)
        {
            OpeningHour openingHour = db.OpeningHours.Find(id);

            if (openingHour == null)
            {
                return(NotFound());
            }

            db.OpeningHours.Remove(openingHour);
            db.SaveChanges();

            return(Ok(openingHour));
        }
        // GET: Admin/OpeningHour/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OpeningHour openingHour = db.OpeningHours.Find(id);

            if (openingHour == null)
            {
                return(HttpNotFound());
            }
            db.OpeningHours.Remove(openingHour);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 17
0
        public void UpdateOpeningHourDayAlreadyExists()
        {
            var openingHours = ZooInfoController.GetAllOpeningHourResults();

            Assert.AreEqual(6, openingHours.Count());

            OpeningHour opHour = new OpeningHour
            {
                id        = 1,
                day       = 2,
                startTime = new TimeSpan(11, 30, 00),
                endTime   = new TimeSpan(12, 0, 0),
            };

            ZooInfoController.UpdateOpeningHour(opHour);
        }
Ejemplo n.º 18
0
        public void UpdateOpeningHourIdDoesntExists()
        {
            var openingHours = ZooInfoController.GetAllOpeningHourResults();

            Assert.AreEqual(6, openingHours.Count());

            OpeningHour opHour = new OpeningHour
            {
                id        = -11,
                day       = 7,
                startTime = new TimeSpan(10, 45, 0),
                endTime   = new TimeSpan(18, 0, 0),
            };

            ZooInfoController.UpdateOpeningHour(opHour);
        }
Ejemplo n.º 19
0
        public void UpdateOpeningHourIdDoesntExists()
        {
            var openingHours = context.GetAllOpeningHours((int)Languages.he);

            Assert.AreEqual(6, openingHours.Count());

            OpeningHour opHour = new OpeningHour
            {
                id        = -11,
                day       = 7,
                startTime = new TimeSpan(10, 45, 0),
                endTime   = new TimeSpan(18, 0, 0),
            };

            context.UpdateOpeningHour(opHour);
        }
Ejemplo n.º 20
0
        public void UpdateOpeningHourDayAlreadyExists()
        {
            var openingHours = context.GetAllOpeningHours((int)Languages.he);

            Assert.AreEqual(6, openingHours.Count());

            OpeningHour opHour = new OpeningHour
            {
                id        = 1,
                day       = 2,
                startTime = new TimeSpan(11, 30, 00),
                endTime   = new TimeSpan(12, 0, 0),
            };

            context.UpdateOpeningHour(opHour);
        }
Ejemplo n.º 21
0
        public void UpdateOpeningHourWrongTime()
        {
            var openingHours = context.GetAllOpeningHours((int)Languages.he);

            Assert.AreEqual(6, openingHours.Count());
            Assert.IsTrue(openingHours.Any(oh => oh.Day == "ראשון"));

            OpeningHour opHour = new OpeningHour
            {
                id        = default(int),
                day       = 5,
                startTime = new TimeSpan(18, 0, 0),
                endTime   = new TimeSpan(9, 45, 0),
            };

            context.UpdateOpeningHour(opHour);
        }
Ejemplo n.º 22
0
        public void UpdateOpeningHourWrongTime()
        {
            var openingHours = ZooInfoController.GetAllOpeningHourResults();

            Assert.AreEqual(6, openingHours.Count());
            Assert.IsTrue(openingHours.Any(oh => oh.Day == "ראשון"));

            OpeningHour opHour = new OpeningHour
            {
                id        = default(int),
                day       = 5,
                startTime = new TimeSpan(18, 0, 0),
                endTime   = new TimeSpan(9, 45, 0),
            };

            ZooInfoController.UpdateOpeningHour(opHour);
        }
Ejemplo n.º 23
0
        public void UpdateOpeningHourAddValidInput()
        {
            var openingHours = context.GetAllOpeningHoursType();

            Assert.AreEqual(6, openingHours.Count());
            Assert.IsTrue(openingHours.Any(oh => oh.day == 1));
            Assert.IsFalse(openingHours.Any(oh => oh.day == 6));

            var openingHourResultHeb = context.GetAllOpeningHours((int)Languages.he);

            Assert.IsFalse(openingHourResultHeb.Any(oh => oh.Day == "שישי"));

            var openingHourResultEn = context.GetAllOpeningHours((int)Languages.en);

            Assert.IsFalse(openingHourResultHeb.Any(oh => oh.Day == "Friday"));

            OpeningHour opHour = new OpeningHour
            {
                id        = default(int),
                day       = 6,
                startTime = new TimeSpan(9, 45, 0),
                endTime   = new TimeSpan(18, 0, 0)
            };

            context.UpdateOpeningHour(opHour);

            openingHours = context.GetAllOpeningHoursType();

            Assert.AreEqual(7, openingHours.Count());
            Assert.IsTrue(openingHours.Any(oh => oh.day == 6));

            //heb
            openingHourResultHeb = context.GetAllOpeningHours((int)Languages.he);
            Assert.AreEqual(7, openingHourResultHeb.Count());
            Assert.IsTrue(openingHourResultHeb.Any(oh => oh.Day == "שישי"));

            openingHourResultEn = context.GetAllOpeningHours((int)Languages.en);
            Assert.AreEqual(7, openingHourResultEn.Count());
            Assert.IsTrue(openingHourResultEn.Any(oh => oh.Day == "Friday"));
        }
Ejemplo n.º 24
0
 public BusinessHour(OpeningHour o)
     : base(dayOfWeek: o.DayOfWeek, hourFrom: o.HourFrom, hourTo: o.HourTo, store: o.Store)
 {
 }
 public bool AddOpeningHour(OpeningHour openingHour)
 {
     Model.OpeningHours.Add(openingHour);
     return(SaveChangesToDB());
 }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            ActivitiesHandler      activitiesHandler      = new ActivitiesHandler();
            AdminHandler           adminHandler           = new AdminHandler();
            ClosedDaysHandler      closedDaysHandler      = new ClosedDaysHandler();
            CompanyHandler         companyHandler         = new CompanyHandler();
            DBHandler              dBHandler              = new DBHandler();
            HallHandler            hallHandler            = new HallHandler();
            LoginHandler           loginHandler           = new LoginHandler();
            OngoingBookingsHandler ongoingBookingsHandler = new OngoingBookingsHandler();
            OpeningHoursHandler    openingHoursHandler    = new OpeningHoursHandler();
            SectionsHandler        sectionsHandler        = new SectionsHandler();
            SingleBookingsHandler  singleBookingsHandler  = new SingleBookingsHandler();
            StatisticsHandler      statisticsHandler      = new StatisticsHandler();

            Hall hall = new Hall()
            {
                Name             = "Klarup Sportshal",
                Address          = "Gammelvej 23, 6900 Ølby",
                AmountOfSections = 6
            };

            hallHandler.AddHall(hall);

            OpeningHour openingHourMonday = new OpeningHour()
            {
                NameOfDay   = "Monday",
                OpeningTime = DateTime.ParseExact("00/01/01 9:00:00 AM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 4:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };
            OpeningHour openingHourTuesday = new OpeningHour()
            {
                NameOfDay   = "Tuesday",
                OpeningTime = DateTime.ParseExact("00/01/01 8:00:00 AM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 4:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };
            OpeningHour openingHourWednesday = new OpeningHour()
            {
                NameOfDay   = "Wednesday",
                OpeningTime = DateTime.ParseExact("00/01/01 5:00:00 AM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 8:30:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };
            OpeningHour openingHourThursday = new OpeningHour()
            {
                NameOfDay   = "Thursday",
                OpeningTime = DateTime.ParseExact("00/01/01 9:00:00 AM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 4:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };
            OpeningHour openingHourFriday = new OpeningHour()
            {
                NameOfDay   = "Friday",
                OpeningTime = DateTime.ParseExact("00/01/01 6:00:00 AM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 3:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };
            OpeningHour openingHourSaturday = new OpeningHour()
            {
                NameOfDay   = "Saturday",
                OpeningTime = DateTime.ParseExact("00/01/01 1:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 10:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };
            OpeningHour openingHourSunday = new OpeningHour()
            {
                NameOfDay   = "Sunday",
                OpeningTime = DateTime.ParseExact("00/01/01 5:00:00 AM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                ClosingTime = DateTime.ParseExact("00/01/01 1:00:00 PM", "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture),
                HallId      = 1
            };

            openingHoursHandler.AddOpeningHour(openingHourMonday);
            openingHoursHandler.AddOpeningHour(openingHourTuesday);
            openingHoursHandler.AddOpeningHour(openingHourWednesday);
            openingHoursHandler.AddOpeningHour(openingHourThursday);
            openingHoursHandler.AddOpeningHour(openingHourFriday);
            openingHoursHandler.AddOpeningHour(openingHourSaturday);
            openingHoursHandler.AddOpeningHour(openingHourSunday);

            Admin admin = new Admin()
            {
                Name     = "Emil Lynge",
                Email    = "*****@*****.**",
                Password = "******",
                HallId   = 1
            };

            adminHandler.AddAdmin(admin);

            Activity activity = new Activity()
            {
                Name             = "Håndboldtræning",
                SectionsRequired = 3,
            };
            Activity activity2 = new Activity()
            {
                Name             = "Håndboldkamp",
                SectionsRequired = 6,
            };
            Activity activity3 = new Activity()
            {
                Name             = "Badmintonbane",
                SectionsRequired = 1,
            };
            Activity activity4 = new Activity()
            {
                Name             = "Badmintonkamp",
                SectionsRequired = 3,
            };
            Activity activity5 = new Activity()
            {
                Name             = "Volleyballtræning",
                SectionsRequired = 3,
            };
            Activity activity6 = new Activity()
            {
                Name             = "Volleyballkamp",
                SectionsRequired = 3,
            };
            Activity activity7 = new Activity()
            {
                Name             = "Floorballtræning",
                SectionsRequired = 1,
            };
            Activity activity8 = new Activity()
            {
                Name             = "Floorballkamp",
                SectionsRequired = 3,
            };

            activitiesHandler.AddActivity(activity);
            activitiesHandler.AddActivity(activity2);
            activitiesHandler.AddActivity(activity3);
            activitiesHandler.AddActivity(activity4);
            activitiesHandler.AddActivity(activity5);
            activitiesHandler.AddActivity(activity6);
            activitiesHandler.AddActivity(activity7);
            activitiesHandler.AddActivity(activity8);

            Console.ReadLine();
            //Company company = new Company()
            //{
            //    Name = "AspIT",
            //    Address = "Carl Gustavsgade 2, Høje Taastrup",
            //    PhoneNumber = "22332244",
            //    Email = "*****@*****.**",
            //    Password = "******"
            //};
            //Company company2 = new Company()
            //{
            //    Name = "FreelanceLynge",
            //    Address = "Egegade 999, Kbh",
            //    PhoneNumber = "23242526",
            //    Email = "*****@*****.**",
            //    Password = "******"
            //};
            //companyHandler.AddCompany(company);
            //companyHandler.AddCompany(company2);
        }
Ejemplo n.º 27
0
        public static void Initialise(IServiceProvider serviceProvider)
        {
            using (var context = new LocationsContext(serviceProvider.GetRequiredService <DbContextOptions <LocationsContext> >()))
            {
                // Check if any locations exist
                if (context.Locations.Any())
                {
                    return; // Database already populated
                }

                context.Locations.AddRange(
                    new Location {
                    Name = "Vivian St, Blackburn", Address = "4 Vivian St", City = "Blackburn", County = "Lancashire", PostCode = "BB2 6LB", Phone = "01379-603039", Latitude = 53.752578, Longitude = -2.506155, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Aigburth St, Blackburn", Address = "404 Aigburth St", City = "Blackburn", County = "Lancashire", PostCode = "BB1 2AA", Phone = "01559-323337", Latitude = 53.74901, Longitude = -2.456874, Type = LocationType.Local
                },
                    new Location {
                    Name = "Pall Mall, Blackpool", Address = "603 Pall Mall", City = "Blackpool", County = "Lancashire", PostCode = "FY3 8ND", Phone = "01694-424205", Latitude = 53.822536, Longitude = -3.01874, Type = LocationType.Local
                },
                    new Location {
                    Name = "Grayson St, Blackpool", Address = "162 Grayson St", City = "Blackpool", County = "Lancashire", PostCode = "FY2 0TD", Phone = "01624-595660", Latitude = 53.838854, Longitude = -3.031963, Type = LocationType.Local
                },
                    new Location {
                    Name = "Britton St, Bolton", Address = "6766 Britton St", City = "Bolton", County = "Greater Manchester", PostCode = "BL1 3EX", Phone = "01912-749219", Latitude = 53.59237, Longitude = -2.450272, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Sussex St, Bolton", Address = "123 Sussex St", City = "Bolton", County = "Greater Manchester", PostCode = "BL1 6PY", Phone = "01457-837447", Latitude = 53.598733, Longitude = -2.44079, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Gloucester Pl, Bolton", Address = "2395 Gloucester Pl", City = "Bolton", County = "Greater Manchester", PostCode = "BL1 6DS", Phone = "01368-497445", Latitude = 53.588641, Longitude = -2.452558, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Nesfield St, Bolton", Address = "1111 Nesfield St", City = "Bolton", County = "Greater Manchester", PostCode = "BL2 2SU", Phone = "01620-435994", Latitude = 53.581686, Longitude = -2.404196, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Clark St, Bolton", Address = "143 Clark St", City = "Bolton", County = "Greater Manchester", PostCode = "BL1 2PS", Phone = "01934-672498", Latitude = 53.583387, Longitude = -2.436702, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Thomaston St, Bolton", Address = "8 Thomaston St", City = "Bolton", County = "Greater Manchester", PostCode = "BL1 8RG", Phone = "01818-292728", Latitude = 53.604071, Longitude = -2.42877, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Covent Garden, Bolton", Address = "4 Covent Garden", City = "Bolton", County = "Greater Manchester", PostCode = "BL4 7AF", Phone = "01333-436799", Latitude = 53.548666, Longitude = -2.395293, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Greig St, Bury", Address = "1175 Greig St", City = "Bury", County = "Greater Manchester", PostCode = "M25 0ZN", Phone = "01532-497454", Latitude = 53.53444, Longitude = -2.287119, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Denison St, Bury", Address = "82 Denison St", City = "Bury", County = "Greater Manchester", PostCode = "M25 1JB", Phone = "01699-467608", Latitude = 53.531421, Longitude = -2.267321, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Pine St, Bury", Address = "79 Pine St", City = "Bury", County = "Greater Manchester", PostCode = "M26 1GH", Phone = "01585-487560", Latitude = 53.552484, Longitude = -2.314139, Type = LocationType.Local
                },
                    new Location {
                    Name = "Britannia Ave, Fylde", Address = "7 Britannia Ave", City = "Fylde", County = "Lancashire", PostCode = "PR4 3RQ", Phone = "01911-775929", Latitude = 53.771774, Longitude = -2.842142, Type = LocationType.Local
                },
                    new Location {
                    Name = "Haddock St, Fylde", Address = "7 Haddock St", City = "Fylde", County = "Lancashire", PostCode = "FY8 3TF", Phone = "01574-363346", Latitude = 53.753436, Longitude = -3.008877, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Toxteth St, Hyndburn", Address = "2577 Toxteth St", City = "Hyndburn", County = "Lancashire", PostCode = "BB6 7UN", Phone = "01527-579687", Latitude = 53.798938, Longitude = -2.410003, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Curzon St, Hyndburn", Address = "4679 Curzon St", City = "Hyndburn", County = "Lancashire", PostCode = "BB5 0SJ", Phone = "01354-864473", Latitude = 53.748576, Longitude = -2.374968, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Howe St, Hyndburn", Address = "883 Howe St", City = "Hyndburn", County = "Lancashire", PostCode = "BB5 5TJ", Phone = "01790-887225", Latitude = 53.779748, Longitude = -2.3886, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Lister Rd, Hyndburn", Address = "115 Lister Rd", City = "Hyndburn", County = "Lancashire", PostCode = "BB5 2EY", Phone = "01616-548910", Latitude = 53.749685, Longitude = -2.36503, Type = LocationType.Local
                },
                    new Location {
                    Name = "Sidney Rd, Knowsley", Address = "3833 Sidney Rd", City = "Knowsley", County = "Merseyside", PostCode = "L32 3XS", Phone = "01378-845450", Latitude = 53.468899, Longitude = -2.885106, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Regent St, Lancaster", Address = "94 Regent St", City = "Lancaster", County = "Lancashire", PostCode = "LA6 1DB", Phone = "01478-392232", Latitude = 54.123698, Longitude = -2.731124, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Newlands St, Liverpool", Address = "97 Newlands St", City = "Liverpool", County = "Merseyside", PostCode = "L6 9DU", Phone = "01544-247601", Latitude = 53.417659, Longitude = -2.951391, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Christopher St, Liverpool", Address = "1554 Christopher St", City = "Liverpool", County = "Merseyside", PostCode = "L6 1BG", Phone = "01976-784016", Latitude = 53.415831, Longitude = -2.965193, Type = LocationType.Local
                },
                    new Location {
                    Name = "Ledward St, Liverpool", Address = "7642 Ledward St", City = "Liverpool", County = "Merseyside", PostCode = "L19 0LN", Phone = "01919-185409", Latitude = 53.360775, Longitude = -2.918372, Type = LocationType.Local
                },
                    new Location {
                    Name = "Sherwood St, Liverpool", Address = "4 Sherwood St", City = "Liverpool", County = "Merseyside", PostCode = "L24 6SH", Phone = "01708-724957", Latitude = 53.34501, Longitude = -2.82199, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Blantyre Rd, Liverpool", Address = "236 Blantyre Rd", City = "Liverpool", County = "Merseyside", PostCode = "L6 2EN", Phone = "01982-734773", Latitude = 53.415886, Longitude = -2.96402, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Ogwen St, Manchester", Address = "9548 Ogwen St", City = "Manchester", County = "Greater Manchester", PostCode = "M23 9GB", Phone = "01740-739731", Latitude = 53.391555, Longitude = -2.296035, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Medlock St, Manchester", Address = "74 Medlock St", City = "Manchester", County = "Greater Manchester", PostCode = "M20 1JG", Phone = "01203-684728", Latitude = 53.428648, Longitude = -2.241527, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Edge Grove, Manchester", Address = "7217 Edge Grove", City = "Manchester", County = "Greater Manchester", PostCode = "M22 4ZB", Phone = "01750-379103", Latitude = 53.391563, Longitude = -2.253767, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Townsend St, Oldham", Address = "50 Townsend St", City = "Oldham", County = "Greater Manchester", PostCode = "OL9 0NS", Phone = "01641-726098", Latitude = 53.549016, Longitude = -2.165723, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Chestnut St, Pendle", Address = "8 Chestnut St", City = "Pendle", County = "Lancashire", PostCode = "BB9 6EW", Phone = "01918-999052", Latitude = 53.852294, Longitude = -2.21558, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Clyde Rd, Preston", Address = "93 Clyde Rd", City = "Preston", County = "Lancashire", PostCode = "PR1 6TN", Phone = "01311-567052", Latitude = 53.769736, Longitude = -2.688363, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Hey Green Rd, Preston", Address = "42 Hey Green Rd", City = "Preston", County = "Lancashire", PostCode = "PR1 6TL", Phone = "01752-399931", Latitude = 53.768965, Longitude = -2.688002, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Eldon Place, Burnley", Address = "87 Eldon Place", City = "Burnley", County = "Lancashire", PostCode = "BB12 7RY", Phone = "01315-409372", Latitude = 53.813173, Longitude = -2.364732, Type = LocationType.Local
                },
                    new Location {
                    Name = "Mason St, Rochdale", Address = "77 Mason St", City = "Rochdale", County = "Greater Manchester", PostCode = "OL16 3AW", Phone = "01224-605237", Latitude = 53.621381, Longitude = -2.126743, Type = LocationType.Local
                },
                    new Location {
                    Name = "Westbank Rd, Rochdale", Address = "805 Westbank Rd", City = "Rochdale", County = "Greater Manchester", PostCode = "OL10 2DU", Phone = "01270-562265", Latitude = 53.587718, Longitude = -2.212342, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Seacombe St, Rochdale", Address = "2 Seacombe St", City = "Rochdale", County = "Greater Manchester", PostCode = "OL15 0JP", Phone = "01919-731224", Latitude = 53.645434, Longitude = -2.088364, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Great Howard St, Sefton", Address = "8880 Great Howard St", City = "Sefton", County = "Merseyside", PostCode = "L29 7WD", Phone = "01358-446391", Latitude = 53.509138, Longitude = -2.9869, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Pyramid St, St. Helens", Address = "3 Pyramid St", City = "St. Helens", County = "Merseyside", PostCode = "WA10 3BW", Phone = "01546-942059", Latitude = 53.43894, Longitude = -2.775494, Type = LocationType.Local
                },
                    new Location {
                    Name = "Upper Harrington St, St. Helens", Address = "999 Upper Harrington St", City = "St. Helens", County = "Merseyside", PostCode = "WA12 9WX", Phone = "01754-426672", Latitude = 53.459852, Longitude = -2.639752, Type = LocationType.Local
                },
                    new Location {
                    Name = "Carlton St, St. Helens", Address = "159 Carlton St", City = "St. Helens", County = "Merseyside", PostCode = "WA10 6QG", Phone = "01481-744296", Latitude = 53.468386, Longitude = -2.751687, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Jackson St, St. Helens", Address = "9 Jackson St", City = "St. Helens", County = "Merseyside", PostCode = "WA9 3QW", Phone = "01876-642683", Latitude = 53.445808, Longitude = -2.695068, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Argyle St, Tameside", Address = "1 Argyle St", City = "Tameside", County = "Greater Manchester", PostCode = "SK14 5AR", Phone = "01934-427282", Latitude = 53.44061, Longitude = -2.085739, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Gertrude St, Tameside", Address = "8 Gertrude St", City = "Tameside", County = "Greater Manchester", PostCode = "OL5 0QJ", Phone = "01348-989703", Latitude = 53.522436, Longitude = -2.044472, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Saxon St, Trafford", Address = "260 Saxon St", City = "Trafford", County = "Greater Manchester", PostCode = "M33 4BP", Phone = "01537-525550", Latitude = 53.415061, Longitude = -2.336595, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Queens Rd, Trafford", Address = "792 Queens Rd", City = "Trafford", County = "Greater Manchester", PostCode = "M32 8LR", Phone = "01526-145485", Latitude = 53.444729, Longitude = -2.307727, Type = LocationType.Local
                },
                    new Location {
                    Name = "Pallas St, Trafford", Address = "328 Pallas St", City = "Trafford", County = "Greater Manchester", PostCode = "M32 8LJ", Phone = "01619-237602", Latitude = 53.448859, Longitude = -2.302397, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Picton Rd, Wigan", Address = "553 Picton Rd", City = "Wigan", County = "Greater Manchester", PostCode = "M29 7AA", Phone = "01274-659801", Latitude = 53.500936, Longitude = -2.46088, Type = LocationType.Megastore
                },
                    new Location {
                    Name = "Hampden St, Wirral", Address = "5 Hampden St", City = "Wirral", County = "Merseyside", PostCode = "CH45 4RN", Phone = "01467-142439", Latitude = 53.419971, Longitude = -3.049823, Type = LocationType.Local
                },
                    new Location {
                    Name = "Wellington Rd, Wyre", Address = "493 Wellington Rd", City = "Wyre", County = "Lancashire", PostCode = "PR3 0UH", Phone = "01772-461124", Latitude = 53.864727, Longitude = -2.852797, Type = LocationType.TownStore
                },
                    new Location {
                    Name = "Marine Parade, Wyre", Address = "30 Marine Parade", City = "Wyre", County = "Lancashire", PostCode = "FY5 4FN", Phone = "01994-675650", Latitude = 53.876462, Longitude = -2.999973, Type = LocationType.TownStore
                });

                foreach (var location in context.Locations.Local.ToList())
                {
                    foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
                    {
                        var openingHour = new OpeningHour {
                            Location = location, DayOfWeek = day
                        };

                        switch (location.Type)
                        {
                        case LocationType.Local:
                            openingHour.Opening = 6;
                            openingHour.Closing = 22;
                            break;

                        case LocationType.Megastore:
                            switch (day)
                            {
                            case DayOfWeek.Sunday:
                                openingHour.Opening = 10;
                                openingHour.Closing = 16;
                                break;

                            default:
                                openingHour.Opening = 6;
                                openingHour.Closing = 24;
                                break;
                            }
                            break;

                        case LocationType.TownStore:
                            switch (day)
                            {
                            case DayOfWeek.Sunday:
                                openingHour.Opening = 10;
                                openingHour.Closing = 16;
                                break;

                            default:
                                openingHour.Opening = 6;
                                openingHour.Closing = 22;
                                break;
                            }
                            break;

                        default:
                            break;
                        }

                        context.OpeningHours.Add(openingHour);
                    }
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 28
0
 public DeliveryHour(OpeningHour o)
     : base(dayOfWeek: o.DayOfWeek, hourFrom: o.HourFrom, hourTo: o.HourTo, store: o.Store)
 {
 }
Ejemplo n.º 29
0
        protected override void Seed(CarWashDDDContext context)
        {
            List <ServiceProvider> serviceProviders      = new List <ServiceProvider>();
            ServiceProvider        normalServiceProvider = new ServiceProvider
            {
                Id   = Guid.NewGuid(),
                Name = "Normal"
            };
            ServiceProvider steamServiceProvider = new ServiceProvider
            {
                Id   = Guid.NewGuid(),
                Name = "Steam"
            };

            serviceProviders.Add(normalServiceProvider);
            serviceProviders.Add(steamServiceProvider);
            context.ServiceProviders.AddRange(serviceProviders);

            List <Service> normalServices = new List <Service>();
            Service        normalExterior = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Exterior",
                SlotCount         = 1,
                ServiceProviderId = normalServiceProvider.Id
            };
            Service normalInterior = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Interior",
                SlotCount         = 1,
                ServiceProviderId = normalServiceProvider.Id
            };
            Service normalExteriorInterior = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Exterior + Interior",
                SlotCount         = 1,
                ServiceProviderId = normalServiceProvider.Id
            };
            Service normalExteriorInteriorCarpet = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Exterior + Interior + Carpet",
                SlotCount         = 2,
                ServiceProviderId = normalServiceProvider.Id
            };

            normalServices.Add(normalExterior);
            normalServices.Add(normalInterior);
            normalServices.Add(normalExteriorInterior);
            normalServices.Add(normalExteriorInteriorCarpet);
            context.Services.AddRange(normalServices);

            List <Service> steamServices = new List <Service>();
            Service        steamExterior = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Exterior",
                SlotCount         = 1,
                ServiceProviderId = steamServiceProvider.Id
            };
            Service steamInterior = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Interior",
                SlotCount         = 1,
                ServiceProviderId = steamServiceProvider.Id
            };
            Service steamExteriorInterior = new Service
            {
                Id                = Guid.NewGuid(),
                Name              = "Exterior + Interior",
                SlotCount         = 1,
                ServiceProviderId = steamServiceProvider.Id
            };

            steamServices.Add(steamExterior);
            steamServices.Add(steamInterior);
            steamServices.Add(steamExteriorInterior);
            context.Services.AddRange(steamServices);

            List <OpeningHour> normalOpeningHours = new List <OpeningHour>();
            OpeningHour        normalMonday       = new OpeningHour
            {
                Id = Guid.NewGuid(),
                ServiceProviderId = normalServiceProvider.Id,
                SlotCount         = 11,
                Weekday           = Weekday.Monday
            };
            OpeningHour normalTuesday = new OpeningHour
            {
                Id = Guid.NewGuid(),
                ServiceProviderId = normalServiceProvider.Id,
                SlotCount         = 11,
                Weekday           = Weekday.Tuesday
            };
            OpeningHour normalWednesday = new OpeningHour
            {
                Id = Guid.NewGuid(),
                ServiceProviderId = normalServiceProvider.Id,
                SlotCount         = 11,
                Weekday           = Weekday.Wednesday
            };
            OpeningHour normalThursday = new OpeningHour
            {
                Id = Guid.NewGuid(),
                ServiceProviderId = normalServiceProvider.Id,
                SlotCount         = 11,
                Weekday           = Weekday.Thursday
            };
            OpeningHour normalFriday = new OpeningHour
            {
                Id = Guid.NewGuid(),
                ServiceProviderId = normalServiceProvider.Id,
                SlotCount         = 11,
                Weekday           = Weekday.Friday
            };

            normalOpeningHours.Add(normalMonday);
            normalOpeningHours.Add(normalTuesday);
            normalOpeningHours.Add(normalWednesday);
            normalOpeningHours.Add(normalThursday);
            normalOpeningHours.Add(normalFriday);
            context.OpeningHours.AddRange(normalOpeningHours);

            List <OpeningHour> steamOpeningHours = new List <OpeningHour>();
            OpeningHour        steamTuesday      = new OpeningHour
            {
                Id = Guid.NewGuid(),
                ServiceProviderId = steamServiceProvider.Id,
                SlotCount         = 8,
                Weekday           = Weekday.Tuesday
            };

            steamOpeningHours.Add(steamTuesday);
            context.OpeningHours.AddRange(steamOpeningHours);

            context.SaveChanges();
        }