예제 #1
0
        public static Bill Create(BillModel dto)
        {
            var entity = new Bill();

            entity.Id            = dto.Id;
            entity.BillNumber    = dto.BillNumber;
            entity.BillDate      = dto.BillDate;
            entity.DueDate       = dto.DueDate;
            entity.Description   = dto.Description;
            entity.TotalAmount   = dto.Amount;
            entity.CreatedBy     = dto.CreatedBy;
            entity.CreatedOn     = dto.CreatedOn;
            entity.IsRecurring   = dto.IsRecurring;
            entity.CreatedOn     = dto.CreatedOn;
            entity.CreatedBy     = dto.CreatedBy;
            entity.LastUpdatedBy = dto.LastUpdatedBy;
            entity.LastUpdatedOn = dto.LastUpdatedOn;
            entity.BillStatus    = dto.Status;
            entity.VendorId      = dto.Vendor.Id;
            entity.Vendor        = Create(dto.Vendor);
            entity.CategoryId    = dto.Category.Id;
            entity.Category      = Create(dto.Category);

            if (dto.Items != null && dto.Items.Count > 0)
            {
                entity.BillItems = new List <BillItem>(dto.Items.Count);
                foreach (var dItem in dto.Items)
                {
                    var eItem = Create(dItem);
                    entity.BillItems.Add(eItem);
                }
            }
            else
            {
                entity.BillItems = null;
            }
            //TODO: recurring
            return(entity);
        }
예제 #2
0
        public static BillModel Create(Bill entity)
        {
            var dto = new BillModel();

            dto.Id          = entity.Id;
            dto.BillNumber  = entity.BillNumber;
            dto.BillDate    = entity.BillDate;
            dto.DueDate     = entity.DueDate;
            dto.Description = entity.Description;
            dto.Amount      = entity.TotalAmount;
            dto.Vendor      = Create(entity.Vendor);
            dto.Category    = Create(entity.Category);

            dto.CreatedBy     = entity.CreatedBy;
            dto.CreatedOn     = entity.CreatedOn;
            dto.IsRecurring   = entity.IsRecurring;
            dto.LastUpdatedBy = entity.LastUpdatedBy;
            dto.LastUpdatedOn = entity.LastUpdatedOn;
            dto.Status        = entity.BillStatus;

            if (entity.BillItems != null && entity.BillItems.Count > 0)
            {
                dto.Items = new List <BillItemModel>(entity.BillItems.Count);
                foreach (var eItem in entity.BillItems)
                {
                    var dItem = Create(eItem);
                    dto.Items.Add(dItem);
                }
            }
            else
            {
                dto.Items = null;
            }
            //TODO: recurring

            return(dto);
        }