예제 #1
0
        public IHttpActionResult GetEvents()
        {
            //return Ok(new string[] { "Hello World!", "This is a task." });

            var list = new List<EventsModel>();

            using (var db = new RWBTaskEntitiesConnection())
            {
                list = db.vwEventInformations.Select(ev => new EventsModel
                {
                    Id = ev.Id,
                    Name = ev.Name,
                    SportId = ev.SportId,
                    Sport = ev.SportName,
                    LeagueId = ev.LeagueId,
                    League = ev.LeagueName,
                    CategoryId = ev.CategoryId,
                    Category = ev.CategoryName,
                    StartTime = ev.StartTime,
                }).ToList();

                list.ForEach(l => CalcEventMarket(l, db));

                db.Dispose();
            }
            return Ok(list);
        }
예제 #2
0
        [HttpPost]// POST: /Person/Edit/5
        public ActionResult Edit(int id, MarketPrice obj)
        {
            try
            {
                using (var db = new RWBTaskEntitiesConnection())
                {
                    var price     = db.Lines.FirstOrDefault(l => l.Id == id);
                    var indicator = "UP";
                    if (price != null)
                    {
                        if (obj.Price < price.Price)
                        {
                            indicator = "DOWN";
                        }

                        price.Price = obj.Price;
                        price.Name  = obj.Name;
                        db.SaveChanges();
                    }

                    ExecuteTask(indicator, obj.Id, obj.Price);

                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
예제 #3
0
 private void CalcMarketLine(EventMarket m, RWBTaskEntitiesConnection db)
 {
     m.EventMarketsLines = db.vwEventMarketLines
         .Where(l => l.Id == m.Id)
         .Select(ls => new MarketLine
         {
             MarketId = m.Id,
             Id = ls.Id,
             Name = ls.LineName,
             Price = ls.Price,
             LineId = ls.LineId
         })
         .ToList();
 }
예제 #4
0
 public ActionResult Edit(int id)
 {
     using (var db = new RWBTaskEntitiesConnection())
     {
         var price = db.Lines
                     .Where(l => l.Id == id)
                     .Select(m => new MarketPrice
         {
             Id    = m.Id,
             Name  = m.Name,
             Price = m.Price
         }).SingleOrDefault();
         return(View(price));
     }
 }
예제 #5
0
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";

            using (var db = new RWBTaskEntitiesConnection())
            {
                var list = db.Lines.Where(l => l.MarketId > 0)
                           .Select(m => new MarketPrice
                {
                    Id    = m.Id,
                    Name  = m.Name,
                    Price = m.Price
                })
                           .ToList();
                return(View(list));
            }
        }
예제 #6
0
        private void CalcEventMarket(EventsModel model, RWBTaskEntitiesConnection db)
        {
            db.vwEventMarketLines
                .Where(m => m.EventId == model.Id)
                .ToList().ForEach(li => model.Test.Add(li.MarketName + " - Live: " + li.IsLive));


            model.EventMarkets = db.vwEventMarketLines
                .Where(m => m.EventId == model.Id)
                .Select(sm => new EventMarket
                {
                    Id = sm.Id,
                    Name = sm.MarketName,
                    IsLive = sm.IsLive,
                    LineName = sm.LineName,
                    Price = sm.Price,
                    EventId = sm.EventId,
                    LineId = sm.LineId
                })
                .ToList();
            //model.EventMarkets.ForEach(m => CalcMarketLine(m, db));
        }