コード例 #1
0
        /// <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);
        }
コード例 #2
0
        public ActionResult DeleteGlassSlat([FromBody] WoodGlassSlat glassSlat)
        {
            if (glassSlat == null || glassSlat.Id < 1)
            {
                return(BadRequest());
            }

            wMan.DeleteGlassSlat(glassSlat.Id);

            return(Ok());
        }
コード例 #3
0
        //=== 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);
        }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
 public int SaveGlassSlat([FromBody] WoodGlassSlat glassSlat)
 {
     return(wMan.SaveGlassSlat(glassSlat));
 }