public async Task <IHttpActionResult> PostSpurGear(SpurGear spurGear) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SpurGears.Add(spurGear); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (SpurGearExists(spurGear.TypeID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = spurGear.TypeID }, spurGear)); }
public async Task <IHttpActionResult> PutSpurGear(string id, SpurGear spurGear) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != spurGear.TypeID) { return(BadRequest()); } db.Entry(spurGear).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpurGearExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/*outsideDiameter, numberOfTeeth * pitchDiameter, toothThickness, addendum, workingDepth, wholeDepth, circularPitch * baseCircularPitchAngle, toothThicknessAngle*/ public void TestCalculateParams(params object[] args) { var outsideDiameter = (float)args[0]; var numberOfTeeth = (int)args[1]; var spurGearEntity = new SpurGearEntity { CalculationStrategy = new SpurGearCalculationStrategyByNumberOfTeethAndOutsideDiameter() }; var spurGear = SpurGear.Create(1f, 1f, 1f, numberOfTeeth, 0f, 20f); spurGearEntity.Geometry = spurGear; spurGearEntity.OutsideDiameter = outsideDiameter; var pitchDiameter = (float)args[2]; var toothThickness = (float)args[3]; var addendum = (float)args[4]; var workingDepth = (float)args[5]; var wholeDepth = (float)args[6]; var circularPitch = (float)args[7]; Assert.AreEqual(pitchDiameter, spurGear.PitchDiameter, 0.01); Assert.AreEqual(toothThickness, spurGear.ToothThickness, 0.01); Assert.AreEqual(addendum, spurGear.Addendum, 0.01); Assert.AreEqual(workingDepth, spurGear.WorkingDepth, 0.01); Assert.AreEqual(wholeDepth, spurGear.WholeDepth, 0.01); Assert.AreEqual(circularPitch, spurGear.CircularPitch, 0.01); }
public async Task <IHttpActionResult> GetSpurGear(string id) { SpurGear spurGear = await db.SpurGears.FindAsync(id); if (spurGear == null) { return(NotFound()); } return(Ok(spurGear)); }
public async Task <IHttpActionResult> DeleteSpurGear(string id) { SpurGear spurGear = await db.SpurGears.FindAsync(id); if (spurGear == null) { return(NotFound()); } db.SpurGears.Remove(spurGear); await db.SaveChangesAsync(); return(Ok(spurGear)); }
/// <summary> /// Create the <see cref="SpurGear" />. /// </summary> /// <returns></returns> public override SpurGear CreateSpurGear() { return(SpurGear.Create(4f, 0f, 0.5f, 10, 0, 20f)); }