Beispiel #1
0
        //public async Task<ScreenContract> GetByIdAsync(int id)
        //{
        //    try
        //    {
        //        var screen = await _screenService.GetIdAsync(id);
        //        return screen.Cast<ScreenContract>();
        //    }
        //    catch (Exception e)
        //    {
        //        LogFile.Create(e, Log);
        //        throw new Exception("Erro on the method GetByIdAsync " + e.Message);
        //    }
        //}

        public ScreenContract GetByName(string name)
        {
            try
            {
                var screen = _screenService.Get(t => t.Nome == name);
                return(screen.Cast <ScreenContract>());
            }
            catch (Exception e)
            {
                LogFile.Create(e, Log);
                throw new Exception("Erro on the method GetByName: " + e.Message);
            }
        }
Beispiel #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 ActionResult Index(int idPag = 0)
        {
            try
            {
                _pagination.PaginaAtual     = idPag;
                _pagination.QtdeItensPagina = 20;

                var entidade = _screenService.Get(_pagination);
                var model    = Mapper.Map <IEnumerable <Screen>, IEnumerable <ScreenModel> >(entidade);

                var paginar = _pagination.CalculatePaging(_pagination, _screenService.Count());
                ViewBag.PaginaAtual = paginar.PaginaAtual;
                ViewBag.QtdePaginas = paginar.QtdePaginas;

                return(View(model));
            }
            catch (Exception e)
            {
                ShowMessageDialog(MensagensResource.ErroCarregar, e);
                return(RedirectToAction("Index", "Home"));
            }
        }
        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;
            }
        }
Beispiel #5
0
 public async Task <string> Get()
 {
     return(await _service.Get(HttpContext.RequestAborted));
 }