public JsonResult SelectPotion(int id)
        {
            var context = new PCContext();
            var potion  = context.Potions
                          .Where(m => m.Id == id)
                          .FirstOrDefault();

            if (potion != null)
            {
                WebSocketManager.Broadcast(new ServerMessage()
                {
                    Command = ServerMessage.Commands.Selected,
                    Content = POTION_HTML_ID_PREFIX + id
                });
                if (!potion.Selected)
                {
                    potion.Selected = true;
                    context.SaveChanges();
                }
                return(Json(new JsonResponse <string>()
                {
                    Code = 200,
                    Result = potion.Description
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new JsonResponse <string>()
                {
                    Code = 404,
                    Result = "Not found"
                }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
 protected void Application_Start(object sender, EventArgs e)
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     Components.WebSocketManager wsh = new Components.WebSocketManager();
     using (PCContext context = new PCContext()) {
     }
 }
        public ActionResult PotionsGrid()
        {
            var     context = new PCContext();
            var     potions = context.Potions.ToList();
            decimal cols    = 12;
            decimal count   = (decimal)potions.Count;
            int     rows    = (int)Math.Ceiling(count / cols);

            ViewBag.potionsGrid = new List <List <Potion> >(rows);
            int rowIndex = -1;

            for (int i = 0, iMax = potions.Count; i < iMax; i++)
            {
                if (i % cols == 0)
                {
                    rowIndex++;
                    ViewBag.potionsGrid.Add(new List <Potion>());
                }

                ViewBag.potionsGrid[rowIndex].Add(potions.ElementAt(0));
                potions.RemoveAt(0);
            }
            return(PartialView("_PotionsGrid"));
        }
 public HomeController(PCContext context)
 {
     _context = context;
 }
Ejemplo n.º 5
0
 public CategoryService(PCContext pCContext)
 {
     _context = pCContext;
 }
 public CourseService(PCContext pCContext)
 {
     _context = pCContext;
 }
Ejemplo n.º 7
0
 public ProductController(PCContext context)
 {
     _context = context;
 }