public IHttpActionResult PutLocomotiveType(int id, LocomotiveType locomotiveType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != locomotiveType.TypeId) { return(BadRequest()); } db.Entry(locomotiveType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LocomotiveTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetLocomotiveType(int id) { LocomotiveType locomotiveType = db.LocomotiveTypeEF.Find(id); if (locomotiveType == null) { return(NotFound()); } return(Ok(locomotiveType)); }
public IHttpActionResult PostLocomotiveType(LocomotiveType locomotiveType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.LocomotiveTypeEF.Add(locomotiveType); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = locomotiveType.TypeId }, locomotiveType)); }
public IHttpActionResult DeleteLocomotiveType(int id) { LocomotiveType locomotiveType = db.LocomotiveTypeEF.Find(id); if (locomotiveType == null) { return(NotFound()); } db.LocomotiveTypeEF.Remove(locomotiveType); db.SaveChanges(); return(Ok(locomotiveType)); }
public async Task <ActionResult <LocomotiveTypeModel> > Create(LocomotiveTypeModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var locomotiveType = new LocomotiveType { Family = model.Family, Manufacturer = model.Manufacturer, Name = model.Name }; await _locomotiveTypeRepository.CreateAsync(locomotiveType); model = _mapper.Map <LocomotiveTypeModel>(locomotiveType); return(CreatedAtAction(nameof(GetById), new { id = locomotiveType.Id }, model)); }
public void SetFilter(int listNumber) { filterType = LocomotiveType.All; filterListNumber = listNumber; SetItemsSource(); }
public void SetFilter(LocomotiveType lt) { filterType = lt; filterListNumber = 0; SetItemsSource(); }
public Locomotive(string name, string serialNumber, LocomotiveType type) { Name = name; SerialNumber = serialNumber; Type = type; }
private static string LocomotiveTypeGroupToText(LocomotiveType t) { switch (t) { case LocomotiveType.Steam: return Labels.Steam.ToCapital(); case LocomotiveType.Diesel: return Labels.Diesel.ToCapital(); case LocomotiveType.Electric: return Labels.Electric.ToCapital(); case LocomotiveType.Misc: default: return Labels.Misc.ToCapital(); } }