public IActionResult Post([FromBody] TurbineViewModel model)
        {
            if (model == null)
            {
                return(new StatusCodeResult(500));
            }

            var turbine = DbContext.Turbines.Where(t => t.Id ==
                                                   model.Id).FirstOrDefault();

            if (turbine == null)
            {
                return(NotFound(new
                {
                    Error = String.Format("Turbine ID {0} has not been found", model.Id)
                }));
            }

            turbine.SerialNumber  = model.SerialNumber;
            turbine.TurbineTypeId = model.TurbineTypeId;

            DbContext.SaveChanges();

            return(new JsonResult(
                       turbine.Adapt <TurbineViewModel>(),
                       JsonSettings));
        }
        public IActionResult GetTurbineTypeList()
        {
            var turbineModel = new TurbineViewModel();
            var turbineTypes = DbContext.TurbineTypes.OrderBy(t => t.Id).ToArray();

            foreach (var t in turbineTypes)
            {
                turbineModel.TurbineTypes.Add(t.Adapt <TurbineTypeViewModel>());
            }

            return(new JsonResult(turbineModel, JsonSettings));
        }
        public IActionResult Put([FromBody] TurbineViewModel model)
        {
            if (model == null)
            {
                return(new StatusCodeResult(500));
            }

            var turbine = model.Adapt <Turbine>();

            DbContext.Turbines.Add(turbine);
            DbContext.SaveChanges();

            return(new JsonResult(
                       turbine.Adapt <TurbineViewModel>(),
                       JsonSettings));
        }