コード例 #1
0
        protected override BookingStepConfig DoPostPutDto(Client currentClient, BookingStepConfigDTO dto, BookingStepConfig entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new BookingStepConfig();
            }
            GetMapper.Map <BookingStepConfigDTO, BookingStepConfig>(dto, entity);
            if (dto.BookingSteps != null)
            {
                BookingStepRepository.DeleteRange(entity.BookingSteps.Where(d => !dto.BookingSteps.Any(x => x.Id == d.Id)));
                dto.BookingSteps.ForEach(bookingStep =>
                {
                    if (entity.BookingSteps.Count != 0 && bookingStep.Id != 0 &&
                        entity.BookingSteps.Find(p => p.Id == bookingStep.Id) != null)
                    {
                        return;
                    }
                    BookingStep toAdd = BookingStepService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, bookingStep, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.BookingSteps.Add(toAdd);
                    }
                });
            }
            return(entity);
        }
コード例 #2
0
        public void DeleteBookingStep()
        {
            BookingStep toDelete1 = ctx.BookingStepSet.FirstOrDefault(p => p.Title == "WAITING_CONFIRMATION");
            BookingStep toDelete2 = ctx.BookingStepSet.FirstOrDefault(p => p.Title == "WAITING_PAYMENT");

            repo.Delete(toDelete1);
            repo.Save();
            repo.Delete(toDelete2);
            repo.Save();

            Assert.IsNotNull(ctx.BookingStepSet.FirstOrDefault(p => p.Title == "VALIDATE"));
            Assert.IsNotNull(ctx.BookingStepConfigSet.FirstOrDefault(p => p.Title == "Room Steps"));
            Assert.IsNull(ctx.BookingStepBookingSet.Include("CurrentStep").FirstOrDefault(p => p.CurrentStep.Id == toDelete1.Id));
        }