示例#1
0
        private void generateStatisticData()
        {
            IEnumerable <VashmagazinApartment> apartments = _vashmagazinRepository.GetListOfLastApartments();
            IEnumerable <string>    districts             = _vashmagazinRepository.GetDistinctDistricts(apartments);
            IEnumerable <Statistic> statistics            = _statisticRepository.GetAllStatistics();

            foreach (Statistic statistic in statistics)
            {
                statistic.IsOld = true;
            }
            _statisticRepository.SaveChanges();

            foreach (string district in districts)
            {
                IEnumerable <VashmagazinApartment> apartmentsInDistrict = apartments.Where(a => (a.Address.District == district) && (a.Price > 0) && (a.TotalSquare.Value > 0) && (a.TotalSquare.Unit == SquareUnit.SquareMeters));
                double    p = apartmentsInDistrict.Average(a => (double)a.Price / a.TotalSquare.Value);
                decimal   avaragePricePerMeter = (decimal)p;
                Statistic stat = new Statistic();
                stat.District      = district;
                stat.Date          = DateTime.Today;
                stat.IsOld         = false;
                stat.PricePerMeter = avaragePricePerMeter;
                _statisticRepository.Add(stat);
            }
            _statisticRepository.SaveChanges();
        }
示例#2
0
        public async Task Handle(IMessageContext context, AddContactInformationEvent message)
        {
            Console.WriteLine("AddContactInformationEvent occured");

            statisticRepository.Add(new Statistic(personId: message.personId, location: message.location, phoneNumber: message.phoneNumber));
            await statisticRepository.UnitOfWork.SaveChangesAsync();

            return;
        }
        public ActionResult Create([Bind(Include = "StatisticID,PlayerID,MatchID,goals,assists,minutes")] Statistic statistic)
        {
            if (ModelState.IsValid)
            {
                _statisticRepository.Add(statistic);
                _statisticRepository.Save();
                return(RedirectToAction("Index"));
            }

            ViewBag.MatchID  = new SelectList(_statisticRepository.GetAllMatches(), "MatchID", "City", statistic.MatchID);
            ViewBag.PlayerID = new SelectList(_statisticRepository.GetAllPlayers(), "ID", "LastName", statistic.PlayerID);
            return(View(statistic));
        }
示例#4
0
 public void Add(Statistic statistic)
 {
     _statisticRepository.Add(statistic);
 }