public IHttpActionResult GetSmartGridModel(int id) { var uow = new UnitOfWork <SmartGridModel>(_db); SmartGridModel smartGridModel = uow.Repository.Read(id); if (smartGridModel == null) { return(NotFound()); } return(Ok(smartGridModel)); }
public IHttpActionResult PostSmartGridModel(SmartGridModel smartGridModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var uow = new UnitOfWork <SmartGridModel>(_db); //smartGridModel.TimeStamp = DateTime.Now; uow.Repository.Create(smartGridModel); uow.Commit(); return(CreatedAtRoute("DefaultApi", new { id = smartGridModel.SmartGridId }, smartGridModel)); }