/// <summary> Saves WoodGlassSlat (new or existing). </summary> /// <param name="glassSlat">The glass Slat to save.</param> public int SaveGlassSlat(WoodGlassSlat glassSlat) { if (glassSlat == null) { throw new CoreException("No Wood Glass Slat specified!"); } // Save WoodKind if (glassSlat.WoodKind != null) { glassSlat.IdWoodKind = SaveKind(glassSlat.WoodKind); } // Insert or update if (glassSlat.Id == 0) { glassSlat.Id = repository.Insert(glassSlat).InsertId.Value; } else { repository.Update(glassSlat); } return(glassSlat.Id); }
public ActionResult DeleteGlassSlat([FromBody] WoodGlassSlat glassSlat) { if (glassSlat == null || glassSlat.Id < 1) { return(BadRequest()); } wMan.DeleteGlassSlat(glassSlat.Id); return(Ok()); }
//=== Manage: Wood Glass Slat /// <summary> Get WoodGlassSlat </summary> /// <param name="woodKind">Retrieve woodKind? Default true.</param> public WoodGlassSlat GetGlassSlat(int id, bool woodKind = true) { // Check if (id < 1) { throw new CoreException("Invalid Id Specified!"); } WoodGlassSlat glassSlat = repository.GetEntity <WoodGlassSlat>(id); if (glassSlat == null) { return(null); } if (woodKind && glassSlat.IdWoodKind.HasValue) { glassSlat.WoodKind = repository.GetEntity <WoodKind>(glassSlat.IdWoodKind.Value); } return(glassSlat); }
/// <summary> Deletes the wood glass slat. </summary> /// <param name="id">The id of the wood glass slat to delete.</param> public void DeleteGlassSlat(int id) { if (id < 1) { return; } WoodGlassSlat glassSlat = repository.GetEntity <WoodGlassSlat>(id); if (glassSlat == null) { return; } // Delete parent repository.Delete(glassSlat); // Delete childs if (glassSlat.IdWoodKind.HasValue) { DeleteKind(glassSlat.IdWoodKind.Value); } }
public int SaveGlassSlat([FromBody] WoodGlassSlat glassSlat) { return(wMan.SaveGlassSlat(glassSlat)); }