예제 #1
0
        public PlantViewModel getModelById(int id)
        {
            Plant          data  = _plantService.GetPlantById(id);
            PlantViewModel model = new PlantViewModel();

            model.Id            = data.Id;
            model.Name          = data.Name;
            model.Location      = data.Location;
            model.PlantInCharge = data.PlantInCharge;
            model.SiteId        = data.SiteId;
            model.SiteName      = _siteService.getSiteNameById(data.SiteId.Value);
            model.Sites         = _siteService.GetAll("").ToArray();
            model.ErrorMessage  = "";
            return(model);
        }
예제 #2
0
        public ActionResult <PlantDTO> GetPlant(long id)
        {
            if (id < 0)
            {
                // this is not a valid identifier - we could do more, but alas, we will not.
                return(NotFound());
            }

            Plant plant = service.GetPlantById(id);

            if (plant == null)
            {
                return(NotFound());
            }

            return(mapper.Map <PlantDTO>(plant));
        }