コード例 #1
0
        public bool AddAttraction(AttractionDTO attractionDTO)
        {
            User user = _repository.GetUserByEmail(attractionDTO.EmailUser);

            if (_repository.CheckUserPriority(user, 20) == false)
            {
                return(false);
            }
            AttractionType attractionType = _repository.GetAttractionTypeByTitle(attractionDTO.Title);
            Location       location       = new Location()
            {
                Address    = attractionDTO.Address,
                PostalCode = attractionDTO.PostalCode
            };

            return(_repository.AddAttraction(new Attraction()
            {
                AttractionType = attractionType,
                User = user,
                Name = attractionDTO.Name,
                Description = attractionDTO.Description,
                Rating = 0,
                PhoneNumber = attractionDTO.PhoneNumber,
                OpenTime = attractionDTO.OpenTime,
                CloseTime = attractionDTO.CloseTime,
                CreateAtractionTime = DateTime.Now,
                Location = location,
                ImagePath = @attractionDTO.Base64ToImage(attractionDTO.Image),
            }));
        }
コード例 #2
0
        public void AddAttractionType(AttractionType attractionType)
        {
            OracleCommand cmd = new OracleCommand("insert_procedure.insert_attraction_type",
                                                  connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.Add("v_TITLE", OracleDbType.Varchar2).Value       = attractionType.Title;
            cmd.Parameters.Add("v_DESCRIPTION", OracleDbType.Varchar2).Value = attractionType.Description;
            cmd.Parameters.Add("v_IMAGE", OracleDbType.Varchar2).Value       = attractionType.ImagePath;

            try
            {
                if (cmd.Connection.State != ConnectionState.Open)
                {
                    cmd.Connection.Open();
                }
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
            finally
            {
                DataBaseConnection.GetDbInstance().CloseDBConnection();
            }
        }
コード例 #3
0
        public bool AddAttractionType(AttractionType attractionType)
        {
            if (_repository.FindAttractionTypeByTitle(attractionType.Title) == true)
            {
                return(false);
            }
            _repository.AddAttractionType(attractionType);
            return(true);
            //_repositoryORC.AddAttractionType(attractionType);
            //var x = _repositoryORC.AddLocation(new DAL.ORC.Location() { });

            /*  _repositoryORC.AddAttraction(new DAL.ORC.Attraction()
             * {
             *    Name = "ceva",
             *    Description = "o descriere",
             *    OpenTime = new TimeSpan(8, 30, 0),
             *    CloseTime = new TimeSpan(20, 0, 0),
             *    ImagePath = "/img/ceva",
             *    AttractionType = new DAL.ORC.AttractionType() { Id = 2 },
             *    Location = new DAL.ORC.Location() { Address = "undeva frumos", PostalCode = 1020312 },
             *    User = new DAL.ORC.User() { Id = 2 }
             * });
             */

            //_repositoryORC.GetAttractions();
            // _repositoryORC.GetAttractionsByType("Muzeu");

            // var x= _repositoryORC.CheckUserPriority(new DAL.ORC.User() { Email = "*****@*****.**" }, 40);

            //var y = _repositoryORC.GetAttractionTypeByTitle("Muzeu");
            //var z = _repositoryORC.GetUserByEmail(attractionType.Title);
            //var comm = _repositoryORC.GetCommentsByAttractionId(1);
            //var user = _repository.GetUserByEmailAndPassword("*****@*****.**", "1234567");
        }
コード例 #4
0
    public List <UserProductData> GetAllAttractionsOfType(AttractionType pType)
    {
        List <UserProductData> newData = new List <UserProductData>();

        newData = productDataList.FindAll(a => a.type == pType);
        return(newData);
    }
コード例 #5
0
    public void Init(AttractionType typeParam, List <UserProductData> userProductDataList)
    {
        type = typeParam;
        attractionsDataAsset = GameManager.Instance.GetAttractionsData();
        AttractionsListData data = dataSO.listData.Find(x => x.type == type);

        if (data == null)
        {
            return; // todo add error?
        }

        switch (type)
        {
        case AttractionType.RIDE:
        {
            InitRideList(data, userProductDataList);
        }
        break;

        case AttractionType.FOOD_AND_BEVERAGE:
        {
            InitFoodAndBeverageList(data, userProductDataList);
        }
        break;

        case AttractionType.RECREATION_AREA:
        {
            InitRecreationAreaList(data, userProductDataList);
        }
        break;

        default:
            break;
        }
    }
コード例 #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            AttractionType attractiontype = db.AttractionTypes.Find(id);

            db.AttractionTypes.Remove(attractiontype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "ID,AttractionType1,DisplayOrder")] AttractionType attractiontype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(attractiontype).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(attractiontype));
 }
コード例 #8
0
        public ActionResult Create([Bind(Include = "ID,AttractionType1,DisplayOrder")] AttractionType attractiontype)
        {
            if (ModelState.IsValid)
            {
                db.AttractionTypes.Add(attractiontype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(attractiontype));
        }
コード例 #9
0
        // GET: /AttractionType/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AttractionType attractiontype = db.AttractionTypes.Find(id);

            if (attractiontype == null)
            {
                return(HttpNotFound());
            }
            return(View(attractiontype));
        }
コード例 #10
0
ファイル: Edit.cshtml.cs プロジェクト: qqdqq/Chris
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AttractionType = await _context.AttractionType.SingleOrDefaultAsync(m => m.Id == id);

            if (AttractionType == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #11
0
        public bool CreateAttractionType(AttractionTypeCreate model)
        {
            var entity =
                new AttractionType()
            {
                OwnerID            = _userID,
                AttractionTypeName = model.AttractionTypeName,
                CreatedUtc         = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.AttractionTypes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #12
0
        public AttractionType GetAttractionTypeByTitle(string title)
        {
            OracleCommand cmd = new OracleCommand("get_function.get_attractiontypedata", connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            OracleParameter v_attraction_type = new OracleParameter("v_attraction_type",
                                                                    OracleDbType.RefCursor, ParameterDirection.ReturnValue);

            cmd.Parameters.Add(v_attraction_type);

            cmd.Parameters.Add("v_title", OracleDbType.Varchar2, ParameterDirection.Input).Value = title;

            try
            {
                if (cmd.Connection.State != ConnectionState.Open)
                {
                    cmd.Connection.Open();
                }
                cmd.ExecuteNonQuery();
                OracleRefCursor  t  = (OracleRefCursor)cmd.Parameters["v_attraction_type"].Value;
                OracleDataReader rd = t.GetDataReader();
                if (rd.Read())
                {
                    AttractionType attraction = new AttractionType()
                    {
                        Id          = rd.GetInt32(0),
                        Title       = rd.GetString(1),
                        Description = rd.GetString(2),
                        ImagePath   = rd.GetString(3)
                    };
                    return(attraction);
                }
                return(null);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
            finally
            {
                DataBaseConnection.GetDbInstance().CloseDBConnection();
            }
            return(null);
        }
コード例 #13
0
ファイル: Delete.cshtml.cs プロジェクト: qqdqq/Chris
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AttractionType = await _context.AttractionType.FindAsync(id);

            if (AttractionType != null)
            {
                _context.AttractionType.Remove(AttractionType);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #14
0
    //public delegate void ActionClick();
    //public event ActionClick onClick ;

    //public void ButtonClick()
    //{
    //    if (onClick != null)
    //    {
    //        onClick();
    //    }
    //}

    public void Init(AttractionType typeParam)
    {
        type = typeParam;
        AttractionTabData data = dataSO.dataList.Find(x => x.type == type);

        if (data == null)
        {
            return; // todo add error?
        }
        icon.sprite = data.icon;

        name.GetComponent <LocalizationComponent>().SetTheLocalizedText(data.Name);
        //ifatu - todo - remove hardcodation very ugly
        //if (type == AttractionType.RIDE)
        //{
        //    currentState = TabItemState.HIGHLIGHT;
        //    backgroundImage.color = highlightColor;
        //}
    }
コード例 #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            Attraction a;

            if (attr.vid == 0)
            {
                a = new Attraction();
            }
            else
            {
                a = attr;
            }
            AttractionType attractiontype = comboBox1.SelectedIndex == (int)AttractionType.Viewport ? AttractionType.Viewport : comboBox1.SelectedIndex == (int)AttractionType.Vechicle ? AttractionType.Vechicle : comboBox1.SelectedIndex == (int)AttractionType.Nature ? AttractionType.Nature : AttractionType.Building;

            a.SetName(textBoxNameAttraction.Text);
            a.SetLongitude(float.Parse(textBoxLongitudeAttraction.Text));
            a.SetLatitude(float.Parse(textBoxLatiudeAttraction.Text));
            a.vtype = attractiontype;

            TripsService.AppFiles.Database.DbService.Update <Attraction>(a);
        }
コード例 #16
0
    public void OnItemBought(Guid guid, AttractionType type, double amount)
    {
        UserProductData product = productDataList.Find(a => a.guid == guid);

        if (product == null) //new item -> add it to the list
        {
            product = new UserProductData
            {
                guid       = guid,
                guidString = guid.ToString(),
                count      = amount,
                level      = 1,
                type       = type
            };
            productDataList.Add(product);
        }
        else
        {
            product.count += amount;
        }
        Save();
    }
コード例 #17
0
    public void Init(
        AttractionType typeParam,
        TabItemState state,
        BasicAtractionData attractionDataParam,
        Transform tabParent,
        Transform listParent,
        AttractionsTab tabObj,
        AttractionsList listObj,
        List <UserProductData> userProductDataList)
    {
        type           = typeParam;
        attractionData = attractionDataParam;

        attractionsTab = Instantiate <AttractionsTab>(tabObj, Vector3.zero, Quaternion.identity);
        attractionsTab.transform.SetParent(tabParent, false);
        attractionsTab.Init(type);
        //attractionsTab.onClick += OnTabClicked;

        attractionsList = Instantiate <AttractionsList>(listObj, Vector3.zero, Quaternion.identity);
        attractionsList.transform.SetParent(listParent, false);
        attractionsList.Init(type, userProductDataList);
        attractionsList.gameObject.SetActive(false);
        SetUIState(state);
    }
コード例 #18
0
ファイル: DbInitializer.cs プロジェクト: qqdqq/tpd
        public static void InitializeDb(ApplicationDbContext context, string adminId)
        {
            if (context.ParkInfo.Any())
            {
                return;
            }

            var pinfo = new ParkInfo[]
            {
                new ParkInfo
                {
                    Name         = "Houston Theme Park",
                    Country      = "USA",
                    State        = "TX",
                    City         = "Houston",
                    ZipCode      = "77042",
                    StreetNumber = "11223",
                    StreetName   = "Grant Rd"
                },
            };

            foreach (ParkInfo pi in pinfo)
            {
                context.ParkInfo.Add(pi);
            }
            context.SaveChanges();

            var phours = new ParkHour[]
            {
                new ParkHour
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    FirstDayOpen = "Monday",
                    LastDayOpen  = "Saturday",
                    WorkingHours = "8:00am - 10:00pm"
                }
            };

            foreach (ParkHour ph in phours)
            {
                var parkHoursInDatabase = context.ParkHours.Where(s => s.ParkInfo.Id == ph.ParkInfoId).SingleOrDefault();
                if (parkHoursInDatabase == null)
                {
                    context.ParkHours.Add(ph);
                }
            }

            context.SaveChanges();


            var weather = new Weather[]
            {
                new Weather
                {
                    Date         = DateTime.Parse("2009-10-03"),
                    Rainout      = false,
                    Temperature  = 70.0m,
                    InchesOfRain = 0.0m
                }
            };

            foreach (Weather w in weather)
            {
                context.Weathers.Add(w);
            }
            context.SaveChanges();


            var dreports = new DailyReport[]
            {
                new DailyReport
                {
                    WeatherId = weather.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id,
                    Date      = DateTime.Parse("2009-10-03")
                }
            };

            foreach (DailyReport dr in dreports)
            {
                context.DailyReports.Add(dr);
            }

            context.SaveChanges();


            var locations = new Location[]
            {
                new Location {
                    Name = "North"
                },
                new Location {
                    Name = "East"
                },
                new Location {
                    Name = "West"
                },
                new Location {
                    Name = "South"
                },
                new Location {
                    Name = "Center"
                }
            };

            foreach (Location l in locations)
            {
                context.Locaitons.Add(l);
            }
            context.SaveChanges();

            var atypes = new AttractionType[]
            {
                new AttractionType {
                    Name = "Roller Coaster"
                },
                new AttractionType {
                    Name = "Merry go Round"
                },
                new AttractionType {
                    Name = "Farris Wheel"
                },
                new AttractionType {
                    Name = "Haunted House"
                },
                new AttractionType {
                    Name = "Water Slide"
                }
            };

            foreach (AttractionType at in atypes)
            {
                context.AttractionTypes.Add(at);
            }
            context.SaveChanges();

            var attractions = new Attraction[]
            {
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Haunted House").Id,
                    LocationId       = locations.Single(s => s.Name == "North").Id,
                    Name             = "Spooky House",
                    Description      = "Boo!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Roller Coaster").Id,
                    LocationId       = locations.Single(s => s.Name == "East").Id,
                    Name             = "Wild Ride",
                    Description      = "Wee!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Water Slide").Id,
                    LocationId       = locations.Single(s => s.Name == "West").Id,
                    Name             = "Water Snake",
                    Description      = "Hiss!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Farris Wheel").Id,
                    LocationId       = locations.Single(s => s.Name == "South").Id,
                    Name             = "Great View",
                    Description      = "Ooh!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Merry go Round").Id,
                    LocationId       = locations.Single(s => s.Name == "Center").Id,
                    Name             = "Spinner",
                    Description      = "Woha!",
                }
            };

            foreach (Attraction a in attractions)
            {
                var attractionsInDatabase = context.Attractions.Where
                                                (s => s.ParkInfo.Id == a.ParkInfoId).SingleOrDefault();
                if (attractionsInDatabase == null)
                {
                    context.Attractions.Add(a);
                }
            }
            context.SaveChanges();

            var avisits = new AttractionVisit[]
            {
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Spinner").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Great View").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Water Snake").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Wild Ride").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Spooky House").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (AttractionVisit av in avisits)
            {
                var attractionVisitsInDatabase = context.AttractionVisits.Where
                                                     (s => s.Attraction.Id == av.AttractionId &&
                                                     s.DailyReport.Id == av.DailyReportId).SingleOrDefault();
                if (attractionVisitsInDatabase == null)
                {
                    context.AttractionVisits.Add(av);
                }
            }
            context.SaveChanges();

            var mrequest = new Maintenance[]
            {
                new Maintenance
                {
                    AttractionId  = 1,
                    Description   = "Spooky House as a leeky pipe",
                    DateRecieved  = DateTime.Parse("2009-10-03"),
                    DateResolved  = DateTime.Parse("2009-10-03"),
                    CurrentStatus = "Still leaky",
                    Cost          = 53.96m,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (Maintenance m in mrequest)
            {
                var maintenanceInDatabase = context.Maintenances.Where
                                                (s => s.Attraction.Id == m.AttractionId &&
                                                s.DailyReport.Id == m.DailyReportId).SingleOrDefault();
                if (maintenanceInDatabase == null)
                {
                    context.Maintenances.Add(m);
                }
            }
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "Center").Id,
                    Name       = "Management"
                },
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "West").Id,
                    Name       = "Maintenance"
                },
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "Center").Id,
                    Name       = "Ride Attendants"
                },
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "South").Id,
                    Name       = "Vendor Employee"
                }
            };

            foreach (Department d in departments)
            {
                var departmentsInDatabase = context.Departments.Where
                                                (s => s.ParkInfo.Id == d.ParkInfoId).SingleOrDefault();
                if (departmentsInDatabase == null)
                {
                    context.Departments.Add(d);
                }
            }
            context.SaveChanges();


            var employees = new Employee[]
            {
                new Employee
                {
                    FirstName    = "Juan",
                    LastName     = "Garcia",
                    Title        = "Ride Attendant",
                    DepartmentId = departments.Single(s => s.Name == "Ride Attendants").Id,
                    HireDate     = DateTime.Parse("2008-04-15"),
                    Salary       = 10.25m
                },
                new Employee
                {
                    FirstName     = "John",
                    MiddleInitial = "H",
                    LastName      = "Smith",
                    Title         = "Ride Attendant",
                    DepartmentId  = departments.Single(s => s.Name == "Ride Attendants").Id,
                    HireDate      = DateTime.Parse("2008-06-16"),
                    Salary        = 8.25m
                },
                new Employee
                {
                    FirstName    = "Sally",
                    LastName     = "Red",
                    Title        = "Ride Attendant",
                    DepartmentId = departments.Single(s => s.Name == "Ride Attendants").Id,
                    HireDate     = DateTime.Parse("2008-05-21"),
                    Salary       = 8.25m
                },
                new Employee
                {
                    FirstName    = "Nick",
                    LastName     = "Rodger",
                    Title        = "Maintenance Crew",
                    DepartmentId = departments.Single(s => s.Name == "Maintenance").Id,
                    HireDate     = DateTime.Parse("2007-09-25"),
                    Salary       = 18.75m
                },
                new Employee
                {
                    FirstName    = "David",
                    LastName     = "Valentino",
                    Title        = "Maintenance Crew",
                    DepartmentId = departments.Single(s => s.Name == "Maintenance").Id,
                    HireDate     = DateTime.Parse("2007-09-15"),
                    Salary       = 18.75m
                },
                new Employee
                {
                    FirstName    = "Leon",
                    LastName     = "Nobody",
                    Title        = "Vendor Cashier",
                    DepartmentId = departments.Single(s => s.Name == "Vendor Employee").Id,
                    HireDate     = DateTime.Parse("2008-02-07"),
                    Salary       = 10.25m
                },
                new Employee
                {
                    FirstName    = "Ashely",
                    LastName     = "Frutiz",
                    Title        = "Manager",
                    DepartmentId = departments.Single(s => s.Name == "Management").Id,
                    HireDate     = DateTime.Parse("2006-07-09"),
                    Salary       = 27.85m
                },
            };

            foreach (Employee e in employees)
            {
                var employeeInDatabase = context.Employees.Where
                                             (s => s.Department.Id == e.DepartmentId).SingleOrDefault();
                if (employeeInDatabase == null)
                {
                    context.Employees.Add(e);
                }
            }
            context.SaveChanges();

            var ttypes = new TicketType[]
            {
                new TicketType
                {
                    Name        = "Basic",
                    Description = "Basic, one time use ticket",
                    Price       = 5.00m,
                    Uses        = 1
                },
                new TicketType
                {
                    Name        = "30-Day",
                    Description = "30 day ticket, good for 30 uses",
                    Price       = 50.00m,
                    Uses        = 30
                },
                new TicketType
                {
                    Name        = "Premium",
                    Description = "Premium ticket, good for 180 uses",
                    Price       = 100.00m,
                    Uses        = 180
                }
            };

            foreach (TicketType tt in ttypes)
            {
                context.TicketTypes.Add(tt);
            }
            context.SaveChanges();

            var visitors = new Visitor[]
            {
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hop",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hope",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hopee",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hopeee",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jeff",
                    LastName    = "Croft",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567891",
                    DateOfBirth = DateTime.Parse("1989-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Joe",
                    LastName    = "Person",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567892",
                    DateOfBirth = DateTime.Parse("1990-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jane",
                    LastName    = "Mot",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567893",
                    DateOfBirth = DateTime.Parse("1991-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jo",
                    LastName    = "Zi",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567894",
                    DateOfBirth = DateTime.Parse("1992-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jello",
                    LastName    = "Yee",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567895",
                    DateOfBirth = DateTime.Parse("1993-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jesus",
                    LastName    = "Xo",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567896",
                    DateOfBirth = DateTime.Parse("1994-04-15"),
                }
            };

            foreach (Visitor vi in visitors)
            {
                context.Visitors.Add(vi);
            }
            context.SaveChanges();

            var tickets = new Ticket[]
            {
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hop").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hope").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hopee").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hopeee").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Croft").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Person").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },

                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Mot").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "30-Day").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Zi").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "30-Day").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Yee").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Premium").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Xo").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (Ticket t in tickets)
            {
                var ticketSalesInDatabase = context.Tickets.Where(s => s.DailyReport.Id == t.DailyReportId).SingleOrDefault();
                if (ticketSalesInDatabase == null)
                {
                    context.Tickets.Add(t);
                }
            }
            context.SaveChanges();



            var vtypes = new VendorType[]
            {
                new VendorType {
                    Name = "Stand"
                },
                new VendorType {
                    Name = "Store"
                },
                new VendorType {
                    Name = "Game"
                },
            };

            foreach (VendorType vt in vtypes)
            {
                context.VendorTypes.Add(vt);
            }
            context.SaveChanges();


            var vendors = new Vendor[]
            {
                new Vendor
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    Name         = "Tacos to Go",
                    Description  = "Sells tacos to people on the go",
                    LocationId   = locations.Single(s => s.Name == "West").Id,
                    VendorTypeId = vtypes.Single(s => s.Name == "Stand").Id,
                },
                new Vendor
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    Name         = "Shoot Them All",
                    Description  = "Shoot down all the targets win prizes",
                    LocationId   = locations.Single(s => s.Name == "East").Id,
                    VendorTypeId = vtypes.Single(s => s.Name == "Game").Id,
                },
                new Vendor
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    Name         = "Park Gifts",
                    Description  = "Gifts for your friends who couldn't be here",
                    LocationId   = locations.Single(s => s.Name == "Center").Id,
                    VendorTypeId = vtypes.Single(s => s.Name == "Store").Id,
                }
            };

            foreach (Vendor ve in vendors)
            {
                var vendorsInDatabase = context.Vendors.Where
                                            (s => s.ParkInfo.Id == ve.ParkInfoId).SingleOrDefault();
                if (vendorsInDatabase == null)
                {
                    context.Vendors.Add(ve);
                }
            }
            context.SaveChanges();

            var vsales = new VendorSale[]
            {
                new VendorSale
                {
                    ReportDate    = DateTime.Parse("2009-10-03"),
                    TotalSales    = 73.85m,
                    SalesGoal     = 100.00m,
                    VendorId      = vendors.Single(s => s.Name == "Park Gifts").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new VendorSale
                {
                    ReportDate    = DateTime.Parse("2009-10-03"),
                    TotalSales    = 150.00m,
                    SalesGoal     = 75.00m,
                    VendorId      = vendors.Single(s => s.Name == "Shoot Them All").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new VendorSale
                {
                    ReportDate    = DateTime.Parse("2009-10-03"),
                    TotalSales    = 100.00m,
                    SalesGoal     = 50.00m,
                    VendorId      = vendors.Single(s => s.Name == "Tacos to Go").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (VendorSale ve in vsales)
            {
                var vendorSalesInDatabase = context.VendorSales.Where
                                                (s => s.Vendor.Id == ve.VendorId &&
                                                s.DailyReport.Id == ve.DailyReportId).SingleOrDefault();
                if (vendorSalesInDatabase == null)
                {
                    context.VendorSales.Add(ve);
                }
            }
            context.SaveChanges();



            /*
             * var pinfo = new ParkInfo[]
             * {
             *  new ParkInfo
             *  {
             *      Name = "Houston Theme Park",
             *      Country = "USA",
             *      State = "TX",
             *      City = "Houston",
             *      ZipCode = "77042",
             *      StreetNumber = "11223",
             *      StreetName = "Grant Rd"
             *  },
             * };
             * foreach (ParkInfo pi in pinfo) { context.ParkInfo.Add(pi); }
             * context.SaveChanges();
             */
            /*
             * var dreports = new DailyReport[]
             * {
             *  new DailyReport
             *  {
             *      WeatherId = weather.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id,
             *      Date = DateTime.Parse("2009-10-03")
             *  }
             * };
             *
             * foreach (DailyReport dr in dreports) { context.DailyReports.Add(dr); }
             *
             * context.SaveChanges();
             */
        }
コード例 #19
0
ファイル: Attraction.cs プロジェクト: mnarowski/inzynieria
 /// <summary>
 /// Typ atrakcji w wycieczce
 /// </summary>
 /// <param name="type">Typ wycieczki</param>
 public virtual void SetType(AttractionType type)
 {
     this.type = type;
 }
コード例 #20
0
ファイル: Attraction.cs プロジェクト: mnarowski/inzynieria
 /// <summary>
 /// Typ atrakcji w wycieczce
 /// </summary>
 /// <param name="type">Typ wycieczki</param>
 public virtual void SetType(AttractionType type)
 {
     this.type = type;
 }
コード例 #21
0
ファイル: Attraction.cs プロジェクト: sebiusz10/inzynieria
 public void SetType(AttractionType type)
 {
     throw new System.Exception("Not implemented");
 }
コード例 #22
0
    IEnumerator followschedule()
    {
        int startTime = (numday == 1) ? 11 : 6;

        startTime += index;
        string start_time = (startTime > 12) ? (startTime - 12).ToString() + "pm" : startTime.ToString() + "am";


        ColorSchedule cc  = dayCss [numday - 1] [index];
        string        end = cc.description.text;

        float x;

        if (cc.activity == Activity.travel)
        {
            MouseOverShowInfo info     = GameObject.Find("Btn" + cc.cityName).GetComponent <MouseOverShowInfo> ();
            AttractionType    at       = info.type;
            Vector2Int        openTime = info.openTime;

            if (openTime.x < startTime && openTime.y + 12 > startTime)
            {
                txtprogress.text = "Day" + numday.ToString() + "\n " + start_time + ":" + "Sally " + end;
                x = ExcitBar.transform.localScale.x;
                if (!visitedPlaces.Contains(cc.cityName))
                {
                    //cal the commute
                    visitedPlaces.Add(cc.cityName);
                    if (at == AttractionType.Natural_Beauty)
                    {
                        x += 0.1f;
                    }
                    else
                    {
                        x += 0.05f;
                    }
                }

                //Debug.Log (visitedPlaces. - 1);
                if (visitedPlaces.Capacity > 0 && visitedPlaces [visitedPlaces.Count - 1] != cc.cityName)
                {
                    string    lastcityname = visitedPlaces [visitedPlaces.Capacity - 1];
                    Transform lastCity     = GameObject.Find("Btn" + lastcityname).transform;
                    Transform thisCity     = GameObject.Find("Btn" + cc.cityName).transform;
                    float     dis          = Vector3.Distance(lastCity.position, thisCity.position);
                    Debug.Log("distance:" + dis);
                }

                ExcitBar.transform.localScale = new Vector3(x + 0.01f, 1, 1);
            }
            else
            {
                txtprogress.text = "Day" + numday.ToString() + "\n " + start_time + ":" + "Sally " + end + ", but it's closed.";
                x = ExcitBar.transform.localScale.x;
                if (x - 0.2f < 0)
                {
                    x = 0.2f;
                }
                ExcitBar.transform.localScale = new Vector3(x - 0.2f, 1, 1);
            }

            x = hungerBar.transform.localScale.x;
            if (x + 0.1f > 1)
            {
                txtprogress.text = "Day" + numday.ToString() + "\n " + start_time + ":" + "Sally " + end + ", but she is too hungry to go on. Failed.";
                //return;
                yield return(new WaitForSeconds(1.0f));

                //restart
                GetComponentInChildren <Text>().text  = "Reschedule";
                GetComponent <Button> ().interactable = true;
                Debug.Log("End");
                x = 0.9f;
            }

            hungerBar.transform.localScale = new Vector3(x + 0.1f, 1, 1);


            x = TiredBar.transform.localScale.x;
            if (x + 0.1f > 1)
            {
                txtprogress.text = "Day" + numday.ToString() + "\n " + start_time + ":" + "Sally " + end + ", but she is too tired to go on. Failed.";
                //return;
                yield return(new WaitForSeconds(1.0f));

                //restart
                GetComponentInChildren <Text>().text  = "Reschedule";
                GetComponent <Button> ().interactable = true;
                Debug.Log("End");
                x = 0.9f;
            }
            TiredBar.transform.localScale = new Vector3(x + 0.1f, 1, 1);
        }
        else if (cc.activity == Activity.haveMeal)
        {
            x = hungerBar.transform.localScale.x;
            if (x - 0.5f < 0)
            {
                x = 0;
            }
            else
            {
                x -= 0.5f;
            }
            hungerBar.transform.localScale = new Vector3(x, 1, 1);
        }
        else if (cc.activity == Activity.accomodate)
        {
            x = TiredBar.transform.localScale.x;
            if (x - 0.5f < 0)
            {
                x = 0;
            }
            else
            {
                x -= 0.5f;
            }
            TiredBar.transform.localScale = new Vector3(x, 1, 1);
        }

        Debug.Log(txtprogress.text);

        index++;
        if (index >= dayCss[numday - 1].Length)
        {
            index = 0;
            numday++;
            if (numday > 3)
            {
                //return;
                yield return(new WaitForSeconds(1.0f));

                //restart
                GetComponentInChildren <Text>().text  = "Reschedule";
                GetComponent <Button> ().interactable = true;
                Debug.Log("End");
            }
            else
            {
                yield return(new WaitForSeconds(1.0f));

                StartCoroutine("followschedule");
            }
        }

        yield return(new WaitForSeconds(1.0f));

        StartCoroutine("followschedule");
    }