示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CatalogLocationModel Update(CatalogLocationModel model)
        {
            // get existed by name
            var existedEntity = GetUnique(model.ParentId, model.Name);

            // check existed
            if (existedEntity == null || existedEntity.Id == model.Id)
            {
                // init new entity
                var entity = new cat_Location();

                // set entity props
                model.FillEntity(ref entity);

                // return
                return(new CatalogLocationModel(cat_LocationServices.Update(entity)));
            }

            // report name existed
            return(null);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CatalogLocationModel Create(CatalogLocationModel model)
        {
            // get existed by name
            var existedEntity = GetUnique(model.ParentId, model.Name);

            // check existed
            if (existedEntity == null)
            {
                // init entity
                var entity = new cat_Location();

                // get entity from db
                model.FillEntity(ref entity);

                // return
                return(new CatalogLocationModel(cat_LocationServices.Create(entity)));
            }

            // report name existed
            return(null);
        }