public PlantManagerViewModel GetPlant(int id) { var result = new PlantManagerViewModel(); var plantModel = _plantManagerService.GetPlant(id); var plant = new PlantViewModel { Id = plantModel.Id, Name = plantModel.Name, Address = plantModel.Address, CustomerName = plantModel.CustomerName, MachineSerials = plantModel.Machines.Select(u => u.Serial).ToList(), Machines = plantModel.Machines.Where(n => n.ExpirationDate == null || n.ExpirationDate > DateTime.UtcNow).Select(n => new UserMachineViewModel { Id = n.Id, Serial = n.Serial }).ToList() }; result.Plant = plant; result.Machines = _userManagerViewService.GetMachinesByCustomer(plantModel.CustomerName, false); return(result); }
public HttpResponseMessage GetMachinesByCustomer(string id) { var result = _userManagerViewService.GetMachinesByCustomer(id); return(Request.CreateResponse(HttpStatusCode.OK, result, MediaTypeHeaderValue.Parse("application/json"))); }