Пример #1
0
        /// <summary>
        /// 새로운 MasterCodeItem을 생성합니다.
        /// </summary>
        /// <param name="masterCode">MasterCode 인스턴스</param>
        /// <param name="itemCode">Item Code</param>
        /// <param name="itemName">Item Name (표시명)</param>
        /// <param name="itemValue">Item Value (값)</param>
        /// <param name="viewOrder">정렬 순서</param>
        /// <returns>새로운 <see cref="MasterCodeItem"/></returns>
        public MasterCodeItem CreateMasterCodeItem(MasterCode masterCode, string itemCode, string itemName, string itemValue, int? viewOrder)
        {
            masterCode.ShouldNotBeNull("masterCode");
            itemCode.ShouldNotBeWhiteSpace("itemCode");

            if(IsDebugEnabled)
                log.Debug(@"새로운 MasterCodeItem을 생성합니다... masterCode={0}, itemCode={1}, itemName={2}, itemValue={3}, viewOrder={4}",
                          masterCode, itemCode, itemName, itemValue, viewOrder);

            var codeItem = new MasterCodeItem(masterCode, itemCode, itemName, itemValue)
                           {
                               ViewOrder = viewOrder
                           };

            masterCode.Items.Add(codeItem);
            //  UnitOfWork.CurrentSession.SaveOrUpdate(masterCode);

            // 정렬 순서를 넣는다.
            if(viewOrder.HasValue == false)
                codeItem.ViewOrder = Math.Max(0, masterCode.Items.Count - 1);

            return Repository<MasterCodeItem>.SaveOrUpdate(codeItem);
        }