//POST: api/unitdetails/ public HttpResponseMessage Post([FromBody] UnitRenoKeys unitKeys) { var repo = new UnitRenovationRepository(new ConstructionEntities()); var unitReno = new UnitRenoKeysTranslator().Translate(unitKeys); repo.Delete(ur => ur.hUnit == unitReno.hUnit && ur.hUnitRenoGrp == unitReno.hUnitRenoGrp); return Request.CreateResponse(HttpStatusCode.OK, unitReno); }
public void Context() { _entities = new ConstructionEntities(); _target = new UnitRenovationRepository(_entities); _deleteTarget = _entities.UnitRenoes.Where(r => r.OrigCompletionDate == null).ToList()[0]; Func<Contexts.UnitReno, bool> expression = (r => r.hUnitRenoGrp == _deleteTarget.hUnitRenoGrp && r.hUnit == _deleteTarget.hUnit); _target.Delete(expression); _results = _entities.UnitRenoes.Where(expression); }
public static void SaveUnitReno(Models.UnitReno model) { var repo = new UnitRenovationRepository(new ConstructionEntities()); var unitRenos = new UnitRenoBuilder().Translate(new List<Models.UnitReno> { model }); repo.Save(unitRenos); }
public void Context() { _entities = new ConstructionEntities(); _target = new UnitRenovationRepository(_entities); _results = _target.Retrieve(reno => reno.OrigCompletionDate != null).ToList(); }
public void Context() { var newRenovation = new Contexts.UnitReno { hUnitRenoGrp = 1, hUnit = 16, EstPrice = 1500 }; _unitRenovations = new List<Contexts.UnitReno> {newRenovation}; _entities = new ConstructionEntities(); //remove existing context before test run if (_entities.UnitRenoes.Any(existingRenovation => existingRenovation.hUnitRenoGrp == newRenovation.hUnitRenoGrp && existingRenovation.hUnit == newRenovation.hUnit)) { _entities.UnitRenoes.Attach(newRenovation); _entities.UnitRenoes.Remove(newRenovation); _entities.SaveChanges(); } _target = new UnitRenovationRepository(_entities); _target.Save(_unitRenovations); _results = _target.Retrieve((r => r.EstPrice == newRenovation.EstPrice)).ToList(); }
public void Context() { _entities = new ConstructionEntities(); _target = new UnitRenovationRepository(_entities); _updateTarget = _entities.UnitRenoes.Where(r => r.OrigCompletionDate != null).ToList()[0]; _originalPrice = _updateTarget.EstPrice; _updateTarget.EstPrice += 1; _target.Save(new List<Contexts.UnitReno> { _updateTarget }); _result = _entities.UnitRenoes.Where(r => r.hUnitRenoGrp == _updateTarget.hUnitRenoGrp && r.hUnit == _updateTarget.hUnit).ToList().First(); }