コード例 #1
0
 protected override AdditionalBooking DoPostPutDto(Client currentClient, AdditionalBookingDTO dto, AdditionalBooking entity, string path, object param)
 {
     if (entity == null)
     {
         entity = new AdditionalBooking();
     }
     else
     {
         if (dto.PriceTTC == null)
         {
             dto.PriceTTC = entity.PriceTTC;
         }
     }
     GetMapper.Map <AdditionalBookingDTO, AdditionalBooking>(dto, entity);
     if (path.StartsWith("AdditionalBookingDTO") && dto.Booking == null)
     {
         validationDictionnary.AddModelError("Booking", GenericError.CANNOT_BE_NULL_OR_EMPTY);
     }
     if (dto.Booking != null && dto.Booking.Id != 0)
     {
         entity.Booking = BookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Booking, currentClient, path);
     }
     if (dto.BillItemCategory != null)
     {
         entity.BillItemCategory = BillItemCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BillItemCategory, currentClient, path);
     }
     if (dto.Tax != null)
     {
         entity.Tax = TaxService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Tax, currentClient, path);
     }
     return(entity);
 }
コード例 #2
0
        protected override Room DoPostPutDto(Client currentClient, RoomDTO dto, Room entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new Room();
            }
            else
            {
                if (dto.RefHide == null)
                {
                    dto.RefHide = entity.RefHide;
                }
                if (dto.Color == null)
                {
                    dto.Color = entity.Color;
                }
            }
            GetMapper.Map <RoomDTO, Room>(dto, entity);
            if (dto.BillItemCategory != null)
            {
                entity.BillItemCategory = BillItemCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BillItemCategory, currentClient, path);
            }
            if (dto.RoomCategory != null)
            {
                entity.RoomCategory = RoomCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.RoomCategory, currentClient, path);
            }
            if (dto.Beds != null)
            {
                BedRepository.DeleteRange(entity.Beds.Where(d => !dto.Beds.Any(x => x.Id == d.Id)));
                dto.Beds.ForEach(bed =>
                {
                    if (entity.Beds.Count != 0 && bed.Id != 0 &&
                        entity.Beds.Find(p => p.Id == bed.Id) != null)
                    {
                        return;
                    }
                    Bed toAdd = BedService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, bed, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.Beds.Add(toAdd);
                    }
                });
            }
            if (dto.Documents != null)
            {
                DocumentRepository.DeleteRange(entity.Documents.Where(d => !dto.Documents.Any(x => x.Id == d.Id)));
                dto.Documents.ForEach(document =>
                {
                    Document toAdd = DocumentService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, document, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.Documents.Add(toAdd);
                    }
                });
            }
            return(entity);
        }
コード例 #3
0
        protected override Product DoPostPutDto(Client currentClient, ProductDTO dto, Product entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new Product();
            }
            else
            {
                if (dto.RefHide == null)
                {
                    dto.RefHide = entity.RefHide;
                }
            }
            GetMapper.Map <ProductDTO, Product>(dto, entity);
            if (dto.BillItemCategory != null)
            {
                entity.BillItemCategory = BillItemCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BillItemCategory, currentClient, path);
            }
            if (dto.ProductCategory != null)
            {
                entity.ProductCategory = ProductCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.ProductCategory, currentClient, path);
            }
            if (dto.Supplier != null)
            {
                entity.Supplier = SupplierService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Supplier, currentClient, path);
            }
            if (dto.Tax != null)
            {
                entity.Tax = TaxService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Tax, currentClient, path);
            }
            if (dto.Documents != null)
            {
                DocumentRepository.DeleteRange(entity.Documents.Where(d => !dto.Documents.Any(x => x.Id == d.Id)));
                dto.Documents.ForEach(document =>
                {
                    if (entity.Documents.Count != 0 && document.Id != 0 &&
                        entity.Documents.Find(p => p.Id == document.Id) != null)
                    {
                        return;
                    }
                    Document toAdd = DocumentService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, document, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.Documents.Add(toAdd);
                    }
                });
            }
            return(entity);
        }
コード例 #4
0
 protected override BillItem DoPostPutDto(Client currentClient, BillItemDTO dto, BillItem entity, string path, object param)
 {
     if (entity == null)
     {
         entity = new BillItem();
     }
     GetMapper.Map(dto, entity);
     if (dto.Bill != null && dto.Bill.Id != null && dto.Bill.Id != 0)
     {
         entity.Bill = BillService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Bill, currentClient, path);
     }
     if (dto.BillItemCategory != null)
     {
         entity.BillItemCategory = BillItemCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BillItemCategory, currentClient, path);
     }
     if (dto.GroupBillItem != null)
     {
         entity.GroupBillItem = GroupBillItemService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.GroupBillItem, currentClient, path);
     }
     return(entity);
 }