public async Task <ActionResult> Home(int id)
        {
            var laboratory = new LaboratoryViewModel();
            var projeto    = new ProjetoOutputModel();

            using (var client = new HttpClient()) {
                client.BaseAddress = new Uri(BaseUrl.URL);
                var response = await client.GetAsync($"api/project/busca?id={id}");

                if (response.IsSuccessStatusCode)
                {
                    var responseContent = await response.Content.ReadAsStringAsync();

                    projeto = JsonConvert.DeserializeObject <ProjetoOutputModel>(responseContent);
                    var documentos = GetProjetoService.ListaDocumentos(projeto);

                    TempData["IdProjeto"]     = projeto.Id;
                    TempData["IdLaboratorio"] = projeto.laboratory.Id;

                    ViewBag.Documentos = documentos;

                    return(View(projeto));
                }
            }

            return(View());
        }
Ejemplo n.º 2
0
        public IActionResult Laboratory(int ID)
        {
            var lab = GetLabById(ID);
            var vm  = new LaboratoryViewModel
            {
                Laboratory = lab
            };

            return(View(vm));
        }
Ejemplo n.º 3
0
        public IActionResult Remove([FromForm] LaboratoryViewModel viewModel)
        {
            var dbLaboratory = _dbContext.Laboratories.FirstOrDefault(l => l.Id == viewModel.Id);

            if (dbLaboratory != null)
            {
                _dbContext.Laboratories.Remove(dbLaboratory);
                _dbContext.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult LaboratoryValidation(string carNumber)
        {
            var newModel = new LaboratoryViewModel();

            newModel = GetLaboratoryModelForCarnumber(carNumber);
            DatabaseHelper.SetUnlockForControls(newModel);
            DatabaseHelper.SetModelCollections(newModel);
            DatabaseHelper.GetAnalisisProperty(newModel);
            ViewData["read"]      = true;
            newModel.IsOnAnalyzes = true;


            return(View(newModel));
        }
Ejemplo n.º 5
0
 public ActionResult Edit(LaboratoryViewModel model)
 {
     if (ModelState.IsValid)
     {
         Laboratory laboratorio = model.ToDomain();
         laboratorio.SetUser(Convert.ToInt32(HttpContext.User.Identity.Name));
         Response response = services.LaboratoryService.Save(laboratorio);
         return(Json(new { Msg = response.Message, Erro = response.Error }));
     }
     else
     {
         return(Json(new { Msg = "CNPJ inválido", Erro = true }));
     }
 }
        private LaboratoryViewModel GetLaboratoryModelForCarnumber(string carNumber)
        {
            var model = new LaboratoryViewModel();

            using (var dl = new OMS())
            {
                var order = DatabaseHelper.GetOrderByCarNumber(carNumber);
                if (order != null)
                {
                    Product product = dl.Products.FirstOrDefault(p => p.Id == order.ProductId);

                    model.OrderId          = order.Id;
                    model.OrderTypeId      = order.OrderTypeId;
                    model.Barcode          = order.Barcode;
                    model.CarNumber        = carNumber;
                    model.TruckNumber      = order.TrailerNumber;
                    model.ProductId        = order.ProductId;
                    model.ClassificationId = order.ClassificationId;
                    model.Placards         = order.Placards;
                    switch (order.OrderTypeId)
                    {
                    case 2:
                    case 3:
                        model.Silage = order.TankNumber.HasValue ?order.TankNumber.Value:0;
                        break;

                    case 4:
                    case 6:
                        model.Tank = order.TankNumber.HasValue ? order.TankNumber.Value : 0;
                        break;

                    default:
                        break;
                    }
                    model.Comment = order.Comment;
                    if (product != null)
                    {
                        model.ProductName = product.Name;
                    }
                    model.ClassificationName = dl.Classifications.Single(c => c.Id == order.ClassificationId).Name;
                }
            }
            return(model);
        }
        public ActionResult Filter(FilterViewModel viewModel)
        {
            try
            {
                using (var context = new UnicesumarBdEntities())
                {
                    var laboratory = new LaboratoryViewModel();

                    laboratory.ListLab = context.ListLaboratory
                                         .Include(p => p.HeadOffice)
                                         .Include(p => p.Block)
                                         .Include(p => p.LaboratoryCapacity)
                                         .Include(p => p.LaboratoryCategory)
                                         .Where(p => p.HeadOfficeId == viewModel.HeadOfficeId)
                                         .Select(p => new LabViewModel
                    {
                        Id                      = p.Id,
                        Name                    = p.Name,
                        HeadOfficeTitle         = p.HeadOffice.Title,
                        BlockTitle              = p.Block.Title,
                        LaboratoryCapacityTitle = p.LaboratoryCapacity.Title,
                        LaboratoryCategoryTitle = p.LaboratoryCategory.Title,
                        BlockId                 = p.BlockId,
                        HeadOfficeId            = p.HeadOfficeId,
                        LaboratoryCategoryId    = p.LaboratoryCategoryId,
                        LaboratoryCapacityId    = p.LaboratoryCapacityId,
                    }).ToList();

                    if (viewModel.BlockId != 0)
                    {
                        laboratory.ListLab = laboratory.ListLab.Where(p => p.BlockId == viewModel.BlockId).ToList();
                    }

                    if (viewModel.LaboratoryCapacityId != 0)
                    {
                        laboratory.ListLab = laboratory.ListLab.Where(p => p.LaboratoryCapacityId == viewModel.LaboratoryCapacityId).ToList();
                    }

                    if (viewModel.LaboratoryCategoryId != 0)
                    {
                        laboratory.ListLab = laboratory.ListLab.Where(p => p.LaboratoryCategoryId == viewModel.LaboratoryCategoryId).ToList();
                    }

                    laboratory.ListHeadOffice = context.ListHeadOffice
                                                .Select(p => new HeadOfficeViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                                .ToList();

                    laboratory.ListBlock = context.ListBlock
                                           .Select(p => new BlockViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                           .ToList();

                    laboratory.ListLaboratoryCategory = context.ListLaboratoryCategory
                                                        .Select(p => new LaboratoryCategoryViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                                        .ToList();

                    laboratory.ListLaboratoryCapacity = context.ListLaboratoryCapacity
                                                        .Select(p => new LaboratoryCapacityViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                                        .ToList();

                    var content = LayoutHelper.GetPartialViewData("_ListLabs", ControllerContext, ViewData, TempData, laboratory.ListLab).ToString();

                    return(Json(content));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public ActionResult Index(LaboratoryViewModel viewModel)
        {
            try
            {
                ViewBag.PageKey = "ViewLabs";

                var userId = Convert.ToInt32(Session["userId"]);

                if (userId == 0)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                using (var context = new UnicesumarBdEntities())
                {
                    var laboratory = new LaboratoryViewModel();

                    laboratory.ListLab = context.ListLaboratory
                                         .Include(p => p.HeadOffice)
                                         .Include(p => p.Block)
                                         .Include(p => p.LaboratoryCapacity)
                                         .Include(p => p.LaboratoryCategory)
                                         .Where(p => p.HeadOfficeId == _headOfficeDefault)
                                         .Select(p => new LabViewModel
                    {
                        Id                      = p.Id,
                        Name                    = p.Name,
                        HeadOfficeTitle         = p.HeadOffice.Title,
                        BlockTitle              = p.Block.Title,
                        LaboratoryCapacityTitle = p.LaboratoryCapacity.Title,
                        LaboratoryCategoryTitle = p.LaboratoryCategory.Title,
                    }).ToList();

                    laboratory.ListHeadOffice = context.ListHeadOffice
                                                .Select(p => new HeadOfficeViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                                .ToList();

                    laboratory.ListBlock = context.ListBlock
                                           .Select(p => new BlockViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                           .ToList();

                    laboratory.ListLaboratoryCategory = context.ListLaboratoryCategory
                                                        .Select(p => new LaboratoryCategoryViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                                        .ToList();

                    laboratory.ListLaboratoryCapacity = context.ListLaboratoryCapacity
                                                        .Select(p => new LaboratoryCapacityViewModel
                    {
                        Id    = p.Id,
                        Title = p.Title,
                    })
                                                        .ToList();

                    return(View(laboratory));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }