public async Task <IActionResult> PutHistoric([FromRoute] Guid id, [FromBody] Historic historic)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != historic.Id)
            {
                return(BadRequest());
            }

            _context.Entry(historic).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HistoricExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async void CommandGetHistoricIsValid_Executed_Success()
        {
            var historicWritingRepository = new Mock <IHistoricWritingRepository>();
            var historicReadingRepository = new Mock <IHistoricReadingRepository>();

            var historicCommand = new HistoricCommand()
            {
                Id = 0, IdRickAndMorty = 1, Location = "Earth 137"
            };
            var entity = new Historic()
            {
                Id = historicCommand.Id, IdRickAndMorty = historicCommand.IdRickAndMorty, Location = historicCommand.Location
            };

            historicWritingRepository.Setup(p => p.AddTravel(It.IsAny <Historic>())).Returns(Task.FromResult(entity));

            var historicCommandHandler = new HistoricCommandHandler(historicReadingRepository.Object, historicWritingRepository.Object);

            var historicDb = await historicCommandHandler.AddTravel(historicCommand);

            var historics = await historicCommandHandler.GetHistoric(historicDb.Id);

            historicReadingRepository.Verify(prop => prop.GetHistoric(It.IsAny <int>()), Times.Once);
            Assert.NotNull(historics);
        }
    void Awake()
    {
        InitTrads();

        canShowHistoric = true;

        canClick = true;

        textWriter = GameObject.FindObjectOfType <TextWriter> ();

        histo = GameObject.FindObjectOfType <Historic> ();

        pauseMenu = GameObject.FindObjectOfType <PauseMenu> ();

        imageHandler = GameObject.FindObjectOfType <ImageHandler> ();

        choiceHandler = GameObject.FindObjectOfType <ChoiceHandler> ();

        sMSHandler = GameObject.FindObjectOfType <SMSHandler> ();

        fader = GameObject.FindObjectOfType <Fader> ();

        menuButton = GameObject.FindGameObjectWithTag("MainCanvas").GetComponentInChildren <Button> ();

        TextManager.LoadText(fileName);
    }
        public async Task <ActionResult <Historic> > AddTravel([FromBody] Historic model)
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                context.Historic.Add(model);
                await context.SaveChangesAsync();

                return(model);
            }
        }
        private void MListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            int position = e.Position;

            Historic h = mHistoric[position];

            trans  = FragmentManager.BeginTransaction();
            dialog = new DialogParkingHistoric(h);
            dialog.Show(trans, "History");
        }
Exemple #6
0
        public async Task <Historic> AddTravel(Historic entity)
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                var historicDb = context.Historic.Add(entity);
                await context.SaveChangesAsync();

                return(historicDb.Entity);
            }
        }
        public async Task <IActionResult> PostHistoric([FromBody] Historic historic)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Historics.Add(historic);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHistoric", new { id = historic.Id }, historic));
        }
 public void InitTest()
 {
     TestData.init();
     m_user = new User(TestData.username, TestData.api_key);
     m_user.setApiClient(new MockApiClient(TestData.username, TestData.api_key));
     m_historic = m_user.createHistoric(
         TestData.definition_hash,
         TestData.historic_start,
         TestData.historic_end,
         TestData.historic_sources,
         TestData.historic_sample,
         TestData.historic_name);
 }
Exemple #9
0
        public TicketTests()
        {
            _nameClientUser  = new Name("Felipe", "Machado");
            _emailClientUser = new Email("*****@*****.**");
            _clientUser      = new ClientUser(_nameClientUser, _emailClientUser, 2, "kkhsaoskeeh", "Grupo Mult", "31985988217");
            _ticket          = new Ticket("00001-0", "title", "Descrição do ticket", ETicketStatusType.Aberta, EPriorityType.Alta, _clientUser);

            _nameInternalUser  = new Name("Felipe", "Machado");
            _emailInternalUser = new Email("*****@*****.**");

            _internalUser = new InternalUser(_nameInternalUser, _emailInternalUser, EAccessLevelType.Analista);
            _historic     = new Historic(_nameInternalUser, _emailInternalUser, "O erro acontece quando eu clino no vai.", EHistoricInteractionType.Interação);
        }
        public ActionResult <bool> Post([FromBody] ExchangePokes _exchangePokes)
        {
            User start = _userService.Get(_exchangePokes.userIdStart);
            User end   = _userService.Get(_exchangePokes.userIdEnd);

            if (start == null || end == null)
            {
                return(BadRequest());
            }

            int sumBESent = _exchangePokes.pokemonsSent.Sum(poke => int.Parse(poke.Base_experience));
            int sumBERec  = _exchangePokes.pokemonsRec.Sum(poke => int.Parse(poke.Base_experience));

            if ((sumBESent < sumBERec - 5 || sumBESent > sumBERec + 5) && (sumBERec < sumBESent - 5 || sumBERec > sumBESent + 5))
            {
                return(BadRequest());
            }

            foreach (Pokemon poke in _exchangePokes.pokemonsSent)
            {
                start.Pokemons.Remove(start.Pokemons.Find(f => f.Id.Equals(poke.Id)));
            }

            foreach (Pokemon poke in _exchangePokes.pokemonsRec)
            {
                end.Pokemons.Remove(end.Pokemons.Find(f => f.Id.Equals(poke.Id)));
            }

            start.Pokemons.AddRange(_exchangePokes.pokemonsRec);
            _userService.Update(start.Id, start);

            end.Pokemons.AddRange(_exchangePokes.pokemonsSent);
            _userService.Update(end.Id, end);

            Historic _hist = new Historic()
            {
                UserStartPointId   = start.Id,
                UserStartPointName = start.Nome,
                PokemonsSent       = _exchangePokes.pokemonsSent,
                UserEndPointId     = end.Id,
                UserEndPointName   = end.Nome,
                PokemonsRec        = _exchangePokes.pokemonsRec
            };

            _hisotircService.Create(_hist);

            return(Accepted());
        }
Exemple #11
0
        private static List <Historic> GetHistory(string symbol, DateTime startDate, DateTime endDate)
        {
            XmlReader xr = _yahooDataProvider.GetHistoryReader(symbol, GetValidDate(startDate), GetValidDate(endDate));

            List <Historic> history = new List <Historic>();

            try
            {
                xr.ReadToFollowing("quote");

                while (xr.Name != "results" && xr.NodeType != XmlNodeType.EndElement)
                {
                    try
                    {
                        //fill business object
                        Historic historic = FillHistoricInfo(xr, false);

                        historic.Symbol = symbol;

                        //add to collection
                        history.Add(historic);
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine("No data loaded for {0}. FillHistoricInfo --> {1}", symbol, ex.Message);
                        return(null);
                    }
                }

                // Set Previous Closes
                for (int i = 0; i < history.Count - 1; i++)
                {
                    history[i].PreviousClose = history[i + 1].Close;
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("GetHistory --> {0}", ex.Message);
            }
            finally
            {
                //close datareader
                HttpUtils.CloseConnections(xr, true);
            }

            return(history.Take(250).ToList());
        }
Exemple #12
0
        public async Task <IActionResult> Buy([FromBody] ShoppingCartModel shoppingCart)
        {
            // Verify if deserialize function return ok
            if (shoppingCart == null)
            {
                logger.LogWarning(LoggingEvents.DeserializeJSON, "Fail to deserialize JSON to ShoppingCartModel type.");
                return(BadRequest(new ErrorResponse("[ERROR] - In Parse JSON! Verify your propertys.")));
            }

            // Get a list of ids to use in complex querys
            var productsId = shoppingCart.Products.Select(c => c.Id);

            var user = await repository.GetAsync <User>(c => c.Id == shoppingCart.UserId);

            if (user == null)
            {
                logger.LogWarning(LoggingEvents.GetItemNotFound, "Get failed, user not found. Id: {0}", user.Id);
                return(BadRequest(new ErrorResponse("[ERROR] - User not found!")));
            }

            logger.LogInformation(LoggingEvents.ListItems, "Get products from shopping cart");
            // Get a list of products using a complex query (producs ids)
            var products = await repository.GetAllAsync <Product>(c => productsId.Contains(c.Id));

            // Make a list of products details and update they quantitys
            var productsDetails = GetProductDetails(products, shoppingCart);

            // Create a new historic
            logger.LogInformation(LoggingEvents.GenerateItems, "Creating a new historic of shopping for User: {0}", user.Email);
            Historic newHistoric = new Historic(shoppingCart.Description);

            newHistoric.AddProductsDetail(productsDetails);
            newHistoric.CalcTotal();
            newHistoric.GenerateId();

            //Subtract quantity of products in database
            await UpdateProductsQuantitys(newHistoric.Products.Select(c => c.Product));

            logger.LogInformation(LoggingEvents.InsertItem, "Insert new historic. Id: {0}", newHistoric.Id);
            user.Historics.Add(newHistoric);
            await repository.UpdateAsync <User>(user);

            return(Ok(newHistoric));
        }
Exemple #13
0
        private void lstHistoricsQueries_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            ListView.SelectedListViewItemCollection lvis = GetSelectedItems();
            bool start  = true;
            bool stop   = true;
            bool delete = true;

            if (lvis.Count == 0)
            {
                start = stop = delete = false;
            }
            else
            {
                foreach (ListViewItem lvi in GetSelectedItems())
                {
                    Historic h = (Historic)lvi.Tag;
                    switch (h.getStatus())
                    {
                    case "init":
                        stop = false;
                        break;

                    case "queued":
                    case "submitted":
                    case "prep":
                    case "running":
                    case "finishing":
                        start = false;
                        break;

                    case "finished":
                    case "succeeded":
                    default:
                        start = false;
                        stop  = false;
                        break;
                    }
                }
            }

            mnuStart.Enabled  = btnStart.Enabled = start;
            mnuStop.Enabled   = btnStop.Enabled = stop;
            mnuDelete.Enabled = btnDelete.Enabled = delete;
        }
        public IActionResult Update(int id, [FromBody] Historic item)
        {
            if (item == null || item.ID != id)
            {
                return(BadRequest());
            }

            var historic = _context.Historics.FirstOrDefault(t => t.ID == id);

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

            historic.TimeStamp = item.TimeStamp;

            _context.Historics.Update(historic);
            _context.SaveChanges();
            return(new NoContentResult());
        }
        public async Task <bool> AddToUserHistoricAsync(Historic trail)
        {
            var list = new List <Historic>();

            if (fileService.CheckFile("historic.json", false))
            {
                list = JsonConvert.DeserializeObject <List <Historic> >(await fileService.LoadTextAsync("historic.json"));
            }

            if (list == null)
            {
                list = new List <Historic>();
            }

            list.Add(trail);

            await fileService.SaveTextAsync("historic.json", JsonConvert.SerializeObject(list));

            return(true);
        }
        public IActionResult Create([FromBody] Historic item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            // get last create
            var lastCreate = _context.Historics
                             .FirstOrDefault(x => x.SongID == item.SongID &&
                                             x.UserID == item.UserID);

            if (lastCreate != null)
            {
                Delete(lastCreate.ID);
            }

            _context.Historics.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetHistoric", new { id = item.ID }, item));
        }
Exemple #17
0
        private static Historic FillHistoricInfo(XmlReader xr, bool closeXmlReader)
        {
            Historic historic = null;

            try
            {
                //read datareader
                bool bContinue = true;
                if (closeXmlReader)
                {
                    bContinue = false;
                    if (!xr.EOF)
                    {
                        bContinue = true;
                    }
                }
                if (bContinue)
                {
                    historic = new Historic();
                    xr.ReadToDescendant("Date");
                    historic.Date          = xr.ReadElementContentAsDateTime();
                    historic.Open          = xr.ReadElementContentAsDouble();
                    historic.High          = xr.ReadElementContentAsDouble();
                    historic.Low           = xr.ReadElementContentAsDouble();
                    historic.Close         = xr.ReadElementContentAsDouble();
                    historic.Volume        = xr.ReadElementContentAsInt();
                    historic.AdjustedClose = xr.ReadElementContentAsDouble();
                    xr.ReadEndElement();
                }
            }
            catch
            {
                throw;
            }

            return(historic);
        }
Exemple #18
0
        public Historic GetHistoricById(int Event_Id)
        {
            Historic item = database.Historics.Where(a => a.Id == Event_Id).SingleOrDefault();

            return(item);
        }
Exemple #19
0
        public static void Initialize(SeekseedsContext context)
        {
            //context.Database.Migrate();
            context.Database.EnsureCreated();

            // Look for any users.
            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }

            var styles = new Style[]
            {
                new Style {
                    Name = "Rock"
                },
                new Style {
                    Name = "Jazz"
                },
                new Style {
                    Name = "Punk"
                },
                new Style {
                    Name = "Folk"
                },
                new Style {
                    Name = "Metal"
                },
                new Style {
                    Name = "Cover"
                },
                new Style {
                    Name = "HipHop"
                },
                new Style {
                    Name = "House"
                },
                new Style {
                    Name = "Reggae"
                },
                new Style {
                    Name = "World"
                }
            };

            foreach (var s in styles)
            {
                context.Styles.Add(s);
            }
            context.SaveChanges();



            var geoCoordinates = new GeoCoordinate[]
            {
                new GeoCoordinate {
                    Latitude = 50.618770, Longitude = 5.556980, City = "Liège", CitySearch = "LIEGE"
                },
                new GeoCoordinate {
                    Latitude = 50.583883, Longitude = 5.499630, City = "Seraing", CitySearch = "SERAING"
                },
                new GeoCoordinate {
                    Latitude = 50.656940, Longitude = 5.528550, City = "Ans", CitySearch = "ANS"
                },
                new GeoCoordinate {
                    Latitude = 50.424640, Longitude = 6.028328, City = "Malmedy", CitySearch = "MALMEDY"
                },
                new GeoCoordinate {
                    Latitude = 50.638320, Longitude = 5.575885, City = "Liège", CitySearch = "LIEGE"
                },
                new GeoCoordinate {
                    Latitude = 50.565641, Longitude = 5.723833, City = "Trooz", CitySearch = "TROOZ"
                },
                new GeoCoordinate {
                    Latitude = 50.609240, Longitude = 5.536660, City = "Liège", CitySearch = "LIEGE"
                },
                new GeoCoordinate {
                    Latitude = 50.590304, Longitude = 5.606921, City = "Chaudfontaine", CitySearch = "CHAUDFONTAINE"
                },
                new GeoCoordinate {
                    Latitude = 50.645470, Longitude = 5.634880, City = "Liège", CitySearch = "LIEGE"
                },
                new GeoCoordinate {
                    Latitude = 50.620590, Longitude = 5.686216, City = "Fléron", CitySearch = "FLERON"
                },
                new GeoCoordinate {
                    Latitude = 50.623204, Longitude = 5.647077, City = "Beyne-Heusay", CitySearch = "BEYNEHEUSAY"
                },
                new GeoCoordinate {
                    Latitude = 50.629203, Longitude = 6.033711, City = "Eupen", CitySearch = "EUPEN"
                },
                new GeoCoordinate {
                    Latitude = 35.673540, Longitude = 139.569960, City = "Tokyo", CitySearch = "TOKYO"
                },
                new GeoCoordinate {
                    Latitude = 19.404311, Longitude = -99.245260, City = "Mexico", CitySearch = "MEXICO"
                },
                new GeoCoordinate {
                    Latitude = 50.651877, Longitude = 5.568298, City = "Liège", CitySearch = "LIEGE"
                },
                new GeoCoordinate {
                    Latitude = 50.627903, Longitude = 5.567151, City = "Liège", CitySearch = "LIEGE"
                }
            };

            foreach (var gc in geoCoordinates)
            {
                context.GeoCoordinates.Add(gc);
            }
            context.SaveChanges();



            var artists = new Artist[]
            {
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.618770 && x.Longitude == 5.556980).ID,
                    Name            = "Arcus",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-1/c1.0.424.424/10418453_863253433716576_5732962819798875562_n.jpg?oh=25d9c423042a47b6f9b0941052fc584c&oe=5A0278D2",
                    FacebookUrl     = "https://www.facebook.com/yokolelemusic/",
                    SoundCloudUrl   = ""
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.583883 && x.Longitude == 5.499630).ID,
                    Name            = "Yokolele",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-1/p480x480/18157522_300793483684723_865777591785619445_n.jpg?oh=32aa33ee7fe62131fdecd22f20b11b7a&oe=5A0E323F",
                    FacebookUrl     = "",
                    SoundCloudUrl   = ""
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.656940 && x.Longitude == 5.528550).ID,
                    Name            = "Tontonkief",
                    PhotoUrl        = "https://yt3.ggpht.com/-SdHBHiUQP2k/AAAAAAAAAAI/AAAAAAAAAAA/fa21BNe0I5w/s88-c-k-no-mo-rj-c0xffffff/photo.jpg",
                    FacebookUrl     = "",
                    SoundCloudUrl   = "https://soundcloud.com/kevin-peters-445511882"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.424640 && x.Longitude == 6.028328).ID,
                    Name            = "Kuwsi",
                    PhotoUrl        = "https://i1.sndcdn.com/avatars-000313154813-4dp3ih-t500x500.jpg",
                    FacebookUrl     = "",
                    SoundCloudUrl   = "https://soundcloud.com/kuwsi/sets/2016-kuwsisel"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.638320 && x.Longitude == 5.575885).ID,
                    Name            = "Kennedy's Bridge",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-9/10537034_10152402593698495_5096346312980121023_n.jpg?oh=7a663a3c0f0ec5fecb985fc66314456c&oe=59D4A75C",
                    FacebookUrl     = "https://www.facebook.com/kennedysbrigde/",
                    SoundCloudUrl   = "https://soundcloud.com/kennedysbridge"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.565641 && x.Longitude == 5.723833).ID,
                    Name            = "FDON",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-1/c9.0.480.480/p480x480/13012711_1599619340359974_1434756275918429363_n.jpg?oh=fc69dfb7f294eeeeed97f6dd8769b252&oe=5A06CBF7",
                    FacebookUrl     = "https://www.facebook.com/fdon.be/",
                    SoundCloudUrl   = "https://soundcloud.com/fdonliege"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.609240 && x.Longitude == 5.536660).ID,
                    Name            = "Toine Thys",
                    PhotoUrl        = "",
                    FacebookUrl     = "https://www.facebook.com/toine.thys/",
                    SoundCloudUrl   = ""
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.590304 && x.Longitude == 5.606921).ID,
                    Name            = "Peppergrains",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-1/p480x480/16142451_1202648463157868_5649141152417201329_n.jpg?oh=788ff6d7e4519d298107f7b6b0556157&oe=5A018F67",
                    FacebookUrl     = "https://www.facebook.com/Peppergrains/",
                    SoundCloudUrl   = "https://soundcloud.com/peppergrainsofficial"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.645470 && x.Longitude == 5.634880).ID,
                    Name            = "Matt Ray",
                    PhotoUrl        = "",
                    FacebookUrl     = "",
                    SoundCloudUrl   = "https://soundcloud.com/philippe-matray"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.620590 && x.Longitude == 5.686216).ID,
                    Name            = "D-Nite",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-1/p480x480/15032798_10154894003425934_3985203443468931393_n.jpg?oh=2f26b5d5fd8353b39d35b4e5ca8aabc3&oe=5A01A6DA",
                    FacebookUrl     = "https://www.facebook.com/compuphonicmax/",
                    SoundCloudUrl   = "https://soundcloud.com/compuphonic-1"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.623204 && x.Longitude == 5.647077).ID,
                    Name            = "Sandoo",
                    PhotoUrl        = "https://scontent.fbru1-1.fna.fbcdn.net/v/t1.0-1/p480x480/1385212_495475797215145_14760639_n.jpg?oh=dc7a213eace5a1d32980ab8f75e5c65e&oe=59CABAB6",
                    FacebookUrl     = "https://www.facebook.com/SANDOO-142205229208872/?pnref=lhc",
                    SoundCloudUrl   = "https://soundcloud.com/sandoo-belgium"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.629203 && x.Longitude == 6.033711).ID,
                    Name            = "Bong Of B",
                    PhotoUrl        = "",
                    FacebookUrl     = "",
                    SoundCloudUrl   = "https://soundcloud.com/bongofb"
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 35.673540 && x.Longitude == 139.569960).ID,
                    Name            = "Kikagaku Moyo",
                    PhotoUrl        = "http://images.sk-static.com/images/media/profile_images/artists/6750884/huge_avatar",
                    FacebookUrl     = "",
                    SoundCloudUrl   = ""
                },
                new Artist
                {
                    GeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 19.404311 && x.Longitude == -99.245260).ID,
                    Name            = "La Castañeda",
                    PhotoUrl        = "http://cps-static.rovicorp.com/3/JPG_400/MI0001/415/MI0001415402.jpg?partner=allrovi.com",
                    FacebookUrl     = "",
                    SoundCloudUrl   = ""
                }
            };

            foreach (var a in artists)
            {
                context.Artists.Add(a);
            }
            context.SaveChanges();



            var songs = new Song[]
            {
                new Song
                {
                    ArtistID = 1,
                    Title    = "Zombie",
                    Duration = new TimeSpan(0, 4, 17),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 1)
                },
                new Song
                {
                    ArtistID = 1,
                    Title    = "Reflexe - animal",
                    Duration = new TimeSpan(0, 2, 19),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 1)
                },
                new Song
                {
                    ArtistID = 2,
                    Title    = "Here comes the sun",
                    Duration = new TimeSpan(0, 3, 07),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 2)
                },
                new Song
                {
                    ArtistID = 2,
                    Title    = "Johnny B Goode",
                    Duration = new TimeSpan(0, 2, 07),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 2)
                },
                new Song
                {
                    ArtistID = 3,
                    Title    = "Beat It",
                    Duration = new TimeSpan(0, 2, 56),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 3)
                },
                new Song
                {
                    ArtistID = 3,
                    Title    = "All of me",
                    Duration = new TimeSpan(0, 2, 25),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 3)
                },
                new Song
                {
                    ArtistID = 4,
                    Title    = "NVR AGN",
                    Duration = new TimeSpan(0, 3, 14),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 4)
                },
                new Song
                {
                    ArtistID = 5,
                    Title    = "Come Closer",
                    Duration = new TimeSpan(0, 3, 38),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 5)
                },
                new Song
                {
                    ArtistID = 6,
                    Title    = "Corona Desert",
                    Duration = new TimeSpan(0, 3, 37),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 6)
                },
                new Song
                {
                    ArtistID = 7,
                    Title    = "Osama",
                    Duration = new TimeSpan(0, 2, 24),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 7)
                },
                new Song
                {
                    ArtistID = 8,
                    Title    = "Bounty Hunter",
                    Duration = new TimeSpan(0, 4, 29),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 8)
                },
                new Song
                {
                    ArtistID = 8,
                    Title    = "Lost Lust",
                    Duration = new TimeSpan(0, 3, 10),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 8)
                },
                new Song
                {
                    ArtistID = 9,
                    Title    = "Ellie",
                    Duration = new TimeSpan(0, 4, 28),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 9)
                },
                new Song
                {
                    ArtistID = 10,
                    Title    = "Fresh Air",
                    Duration = new TimeSpan(0, 7, 12),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 10)
                },
                new Song
                {
                    ArtistID = 10,
                    Title    = "L'après midi à la plage",
                    Duration = new TimeSpan(0, 5, 00),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 10)
                },
                new Song
                {
                    ArtistID = 11,
                    Title    = "Face à la bière",
                    Duration = new TimeSpan(0, 6, 03),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 11)
                },
                new Song
                {
                    ArtistID = 12,
                    Title    = "Hold Me",
                    Duration = new TimeSpan(0, 3, 36),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 12)
                },
                new Song
                {
                    ArtistID = 12,
                    Title    = "Hidden",
                    Duration = new TimeSpan(0, 3, 31),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 12)
                },
                new Song
                {
                    ArtistID = 13,
                    Title    = "Tree Smoke",
                    Duration = new TimeSpan(0, 6, 39),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 13)
                },
                new Song
                {
                    ArtistID = 14,
                    Title    = "Cenit",
                    Duration = new TimeSpan(0, 4, 25),
                    Artist   = context.Artists.FirstOrDefault(x => x.ID == 14)
                }
            };

            foreach (var s in songs)
            {
                context.Songs.Add(s);
            }
            context.SaveChanges();



            var users = new User[]
            {
                new User
                {
                    LastGeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.651877 && x.Longitude == 5.568298).ID,
                    FirstName           = "John",
                    LastName            = "Doe",
                    Email    = "*****@*****.**",
                    Username = "******",
                    Password = "******"
                },
                new User
                {
                    LastGeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.651877 && x.Longitude == 5.568298).ID,
                    FirstName           = "Kenichi",
                    LastName            = "Shinoda",
                    Email    = "*****@*****.**",
                    Username = "******",
                    Password = "******"
                },
                new User
                {
                    LastGeoCoordinateID = geoCoordinates.Single(x => x.Latitude == 50.627903 && x.Longitude == 5.567151).ID,
                    FirstName           = "Joaquin Guzman",
                    LastName            = "Loera",
                    Email    = "*****@*****.**",
                    Username = "******",
                    Password = "******"
                }
            };

            foreach (var u in users)
            {
                context.Users.Add(u);
            }
            context.SaveChanges();



            var historics = new Historic[]
            {
                new Historic
                {
                    SongID    = 19,
                    UserID    = 2,
                    TimeStamp = DateTime.Now,
                    LikeType  = LikeType.Ambassador
                },
                new Historic
                {
                    SongID    = 20,
                    UserID    = 3,
                    TimeStamp = DateTime.Now,
                    LikeType  = LikeType.Ambassador
                }
            };

            foreach (var h in historics)
            {
                context.Historics.Add(h);
            }
            context.SaveChanges();



            var styleSongs = new StyleSong[]
            {
                new StyleSong
                {
                    SongID  = 1,
                    StyleID = 1
                },
                new StyleSong
                {
                    SongID  = 2,
                    StyleID = 1
                },
                new StyleSong
                {
                    SongID  = 3,
                    StyleID = 6
                },
                new StyleSong
                {
                    SongID  = 4,
                    StyleID = 6
                },
                new StyleSong
                {
                    SongID  = 5,
                    StyleID = 6
                },
                new StyleSong
                {
                    SongID  = 6,
                    StyleID = 2
                },
                new StyleSong
                {
                    SongID  = 7,
                    StyleID = 7
                },
                new StyleSong
                {
                    SongID  = 8,
                    StyleID = 1
                },
                new StyleSong
                {
                    SongID  = 9,
                    StyleID = 5
                },
                new StyleSong
                {
                    SongID  = 10,
                    StyleID = 8
                },
                new StyleSong
                {
                    SongID  = 11,
                    StyleID = 1
                },
                new StyleSong
                {
                    SongID  = 12,
                    StyleID = 1
                },
                new StyleSong
                {
                    SongID  = 13,
                    StyleID = 7
                },
                new StyleSong
                {
                    SongID  = 14,
                    StyleID = 8
                },
                new StyleSong
                {
                    SongID  = 15,
                    StyleID = 8
                },
                new StyleSong
                {
                    SongID  = 16,
                    StyleID = 6
                },
                new StyleSong
                {
                    SongID  = 17,
                    StyleID = 7
                },
                new StyleSong
                {
                    SongID  = 18,
                    StyleID = 7
                },
                new StyleSong
                {
                    SongID  = 19,
                    StyleID = 1
                },
                new StyleSong
                {
                    SongID  = 20,
                    StyleID = 1
                }
            };

            foreach (var ss in styleSongs)
            {
                context.StyleSongs.Add(ss);
            }
            context.SaveChanges();
        }
 public void PostHistoric(Historic newHistoric)
 {
     Repository.PostHistoric(newHistoric);
 }
Exemple #21
0
 public void UpdateSeeEvent(Historic festivalEvent)
 {
     db.Entry(festivalEvent).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemple #22
0
 public void AddSeeEvent(Historic festivalEvent)
 {
     db.Historics.Add(festivalEvent);
     db.SaveChanges();
 }
 public DialogParkingHistoric(Historic h)
 {
     mHistory = h;
 }
 public void CleanupTest()
 {
     m_historic = null;
     m_user     = null;
 }
 public void SetLastTrail(Historic historic)
 {
     fileService.SaveTextAsync("lastTrail.json", JsonConvert.SerializeObject(historic));
 }
 public void PutHistoric(int id, Historic upHistoric)
 {
     Repository.PutHistoric(id, upHistoric);
 }
Exemple #27
0
        public Historic GetJazzEventById(int id)
        {
            Historic JazzEvent = db.Historics.Where(a => a.ID == id).Include(n => n.Location).SingleOrDefault();

            return(JazzEvent);
        }
Exemple #28
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            UseWaitCursor = true;
            Enabled       = false;

            string errors = "";

            // Validate stuff
            if (txtName.Text.Trim().Length == 0)
            {
                errors += "Please enter a name for your new Historics query\n";
            }
            if (txtStreamHash.Text.Trim().Length == 0)
            {
                errors += "Please specify a stream hash\n";
            }
            if (lbSourcesSelected.Items.Count == 0)
            {
                errors += "Please select one or more data sources\n";
            }
            if (cmbSampleRate.Text.Length == 0)
            {
                errors += "Please select a sample rate\n";
            }

            if (errors.Length > 0)
            {
                // The data is not good enough to try the API
                MessageBox.Show(this, errors, "Form errors", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // Gather the data
                string        name        = txtName.Text.Trim();
                string        stream_hash = txtStreamHash.Text.Trim();
                DateTime      start_date  = dtStartDate.Value;
                DateTime      end_date    = dtEndDate.Value;
                List <string> sources     = new List <string>();
                foreach (string item in lbSourcesSelected.Items)
                {
                    sources.Add(item.Trim());
                }
                double sample = Convert.ToDouble(cmbSampleRate.Text.Trim().Substring(0, cmbSampleRate.Text.Length - 1));

                // Get the user object and make the call
                User user = Program.Inst().dsuser;
                try
                {
                    Historic h = user.createHistoric(stream_hash, start_date, end_date, sources, sample, name);
                    h.prepare();
                    if (m_frmHistoricsQueriesList != null)
                    {
                        m_frmHistoricsQueriesList.AddOrUpdateHistoricItem(h);
                        m_frmHistoricsQueriesList.SelectHistoric(h.getHash());
                    }
                    else
                    {
                        MessageBox.Show(this, "Historic query '" + h.getHash() + "' created successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    Close();
                }
                catch (DataSiftException ex)
                {
                    MessageBox.Show(this, ex.Message, "API Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            UseWaitCursor = false;
            Enabled       = true;
        }
Exemple #29
0
        public void AddOrUpdateHistoricItem(Historic h, ListViewItem lvi = null)
        {
            if (lstHistoricsQueries.InvokeRequired)
            {
                AddOrUpdateHistoricItemCallback cb = new AddOrUpdateHistoricItemCallback(AddOrUpdateHistoricItem);
                this.Invoke(cb, new object[] { h, lvi });
            }
            else
            {
                lstHistoricsQueries.BeginUpdate();

                try
                {
                    if (lvi == null)
                    {
                        // No ListViewItem given, try to find a matching row
                        foreach (ListViewItem lvi_candidate in lstHistoricsQueries.Items)
                        {
                            if (h.getHash() == ((Historic)lvi_candidate.Tag).getHash())
                            {
                                lvi = lvi_candidate;
                                break;
                            }
                        }
                    }

                    if (h.isDeleted())
                    {
                        if (lvi != null)
                        {
                            lstHistoricsQueries.Items.Remove(lvi);
                        }
                    }
                    else
                    {
                        if (lvi == null)
                        {
                            // Still not found it, add it
                            lvi = lstHistoricsQueries.Items.Add(h.getName());
                            lvi.SubItems.Add(h.getStatus());
                            lvi.SubItems.Add(h.getProgress().ToString());
                            lvi.SubItems.Add(h.getStartDate().ToString());
                            lvi.SubItems.Add(h.getEndDate().ToString());
                            lvi.SubItems.Add(string.Join(", ", h.getSources().ToArray()));
                        }
                        else
                        {
                            // Already exists, update the pieces
                            lvi.SubItems[0].Text = h.getName();
                            lvi.SubItems[1].Text = h.getStatus();
                            lvi.SubItems[2].Text = h.getProgress().ToString();
                            lvi.SubItems[3].Text = h.getStartDate().ToString();
                            lvi.SubItems[4].Text = h.getEndDate().ToString();
                            lvi.SubItems[5].Text = string.Join(", ", h.getSources().ToArray());
                        }

                        // Store the Historic in the item
                        lvi.Tag = h;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                lstHistoricsQueries.EndUpdate();
            }
        }
Exemple #30
0
        public Historic GetSeeEvent(int?id)
        {
            Historic festivalEvent = db.Historics.Find(id);

            return(festivalEvent);
        }