Ejemplo n.º 1
0
        public ActionResult <BoxViewModel> Mark(Guid playerId, Guid boxId)
        {
            var box    = boxService.Get(boxId);
            var player = playerService.Get(playerId);

            if (box == null || player == null)
            {
                return(NotFound());
            }

            if (box.MarkedBy == null)
            {
                using (var unitOfWork = unitOfWorkFactory.Create())
                {
                    box.MarkedById = player.PlayerId;

                    //Add play to match history
                    box.Board.Match.Plays.Add(new Play {
                        PlayerId = player.PlayerId
                    });

                    unitOfWork.Commit();
                }
            }

            return(Ok(new BoxViewModel
            {
                BoxId = box.BoxId
            }));
        }
Ejemplo n.º 2
0
        // GET: Location/Delete/:id
        public ActionResult Delete(int id)
        {
            var            location         = this.locationService.Get(id);
            IBoxService    boxService       = DependencyUtils.Resolve <IBoxService>();
            IScreenService screenService    = DependencyUtils.Resolve <IScreenService>();
            var            boxInLocation    = boxService.Get(a => a.LocationID == id).FirstOrDefault();
            var            screenInLocation = screenService.Get(a => a.LocationID == id).FirstOrDefault();
            bool           result           = false;

            if (location != null && boxInLocation == null && screenInLocation == null)
            {
                this.locationService.Delete(location);
                result = true;
            }
            return(Json(new
            {
                success = result,
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ReceiveLocationId(string id)
        {
            int locationId = Int32.Parse(id);

            try
            {
                //get box list by location ID
                IBoxService    boxService    = DependencyUtils.Resolve <IBoxService>();
                IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>();
                IMapper        mapper        = DependencyUtils.Resolve <IMapper>();
                var            boxs          = boxService.Get().ToList();
                var            boxVMs        = new List <Models.AndroidBoxVM>();

                foreach (var item in boxs)
                {
                    //check boxID is being matched
                    if (deviceService.Get(a => a.BoxID == item.BoxID).FirstOrDefault() == null)
                    {
                        if (item.LocationID == locationId)
                        {
                            var b = new Models.AndroidBoxVM
                            {
                                Name        = item.BoxName,
                                Description = item.Description,
                                BoxId       = item.BoxID,
                                LocationId  = item.LocationID,
                            };
                            boxVMs.Add(b);
                        }
                    }
                }
                IScreenService screenService = DependencyUtils.Resolve <IScreenService>();
                var            screens       = screenService.Get().ToList();
                var            screenVMs     = new List <Models.ScreenVM>();
                foreach (var item in screens)
                {
                    //check boxID is being matched
                    if (deviceService.Get(a => a.ScreenID == item.ScreenID).FirstOrDefault() == null)
                    {
                        if (item.LocationID == locationId)
                        {
                            var b = new Models.ScreenVM
                            {
                                Name         = item.ScreenName,
                                Description  = item.Description,
                                ScreenId     = item.ScreenID,
                                LocationId   = item.LocationID,
                                isHorizontal = item.isHorizontal,
                            };
                            screenVMs.Add(b);
                        }
                    }
                }
                return(Json(new
                {
                    boxListByLocationId = boxVMs,
                    screenListByLocationId = screenVMs
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        //Edit information of a specified by id box
        public ActionResult Edit(int id)
        {
            BoxModel model = Convert(_service.Get(id));//Find box if there exists one

            return(View(model));
        }