public ActionResult Create(BOPrinterCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                setViewBags();

                return(View(model));
            }

            try
            {
                var entity = new Printer()
                {
                    Name = model.Name, IP = model.IP, CompanyId = IdEmpresa, PrinterTypeId = model.PrinterTypeId, Ativa = model.Ativa
                };

                _uow.BOPrinterRepository.Add(entity);

                _uow.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            Notify.Success(Resources.CommonStrings.RegisterCreatedSuccessMessage);
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            var entity = _uow.BOPrinterRepository.Tabela(IdEmpresasPorUsuario).FirstOrDefault(x => x.Id == id);

            if (entity == null)
            {
                throw new HttpException(404, "Not found");
            }

            var model = new BOPrinterCreateViewModel()
            {
                Id            = entity.Id,
                Name          = entity.Name,
                IP            = entity.IP,
                PrinterTypeId = entity.PrinterTypeId,
                Ativa         = entity.Ativa
            };

            setViewBags();

            return(View(model));
        }
        public ActionResult Create()
        {
            setViewBags();
            var viewModel = new BOPrinterCreateViewModel
            {
                Ativa = true
            };

            return(View(viewModel));
        }
        public ActionResult Edit(BOPrinterCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                setViewBags();

                return(View(model));
            }

            try
            {
                var entity = _uow.BOPrinterRepository.Tabela(IdEmpresasPorUsuario).FirstOrDefault(x => x.Id == model.Id);

                if (entity == null)
                {
                    throw new HttpException(404, "Not found");
                }

                entity.Name          = model.Name;
                entity.PrinterTypeId = model.PrinterTypeId;
                entity.CompanyId     = IdEmpresa;
                entity.IP            = model.IP;
                entity.Ativa         = model.Ativa;

                _uow.BOPrinterRepository.Update(entity);

                _uow.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }

            Notify.Success(Resources.CommonStrings.RegisterEditedSuccessMessage);
            return(RedirectToAction("Index"));
        }