예제 #1
0
        public ActionResult Results()
        {
            CatmashContext db = new CatmashContext();

            ViewBag.Title = "Results";
            var Model = db.Cats.OrderByDescending(x => x.Elo).ToList();

            return(View(Model));
        }
예제 #2
0
        public static void InitDb()
        {
            CatmashContext db   = new CatmashContext();
            List <Cat>     Cats = db.Cats.ToList();

            if (Cats.Count == 0)
            {
                using (WebClient httpClient = new WebClient())
                {
                    var jsonData = httpClient.DownloadString(JsonUrl);
                    var data     = JsonConvert.DeserializeObject <CatList>(jsonData);
                    foreach (var catJson in data.images)
                    {
                        db.Cats.Add(new Cat {
                            Elo = 1000, Name = catJson.id, PhotoUrl = catJson.url
                        });
                    }
                    db.SaveChanges();
                }
            }
        }
예제 #3
0
 public CatService(CatmashContext context)
 {
     _context = context;
 }
예제 #4
0
 public CatController(CatmashContext context)
 {
     _catService = new CatService(context);
 }