Ejemplo n.º 1
0
        protected override void DoPut(Client currentClient, BookingStepBooking entity, object param)
        {
            var origCopy = BookingStepBookingRepository.GetBookingStepBookingById(entity.Id, currentClient.Id);

            if (origCopy.BookingStepConfig.Id != entity.BookingStepConfig.Id)
            {
                entity.CurrentStep = BookingStepRepository.GetFirstBookingStep(entity.BookingStepConfig.Id, currentClient.Id);
            }
            if (origCopy.CurrentStep.Id != entity.CurrentStep.Id)
            {
                entity.MailSent = 0;
                ValidateBooking(entity);
                entity.DateCurrentStepChanged = DateTime.UtcNow;
            }
        }
Ejemplo n.º 2
0
        public virtual MailLog MailSteps(Client currentClient, MailBookingModel model, object param)
        {
            ValidateNull <MailBookingModel>(model);

            MailLog         log             = new MailLog();
            HomeConfig      hc              = null;
            Document        body            = null;
            List <Document> listAttachments = null;

            BookingStepBookingRepository.includes.Add("CurrentStep");
            BookingStepBookingRepository.includes.Add("CurrentStep.Documents");
            BookingStepBookingRepository.includes.Add("CurrentStep.MailTemplate");
            BookingStepBookingRepository.includes.Add("Booking");
            BookingStepBookingRepository.includes.Add("Booking.People");
            BookingStepBooking b = BookingStepBookingRepository.GetBookingStepBookingById(model.BookingId, currentClient.Id);

            if (b == null)
            {
                validationDictionnary.AddModelError(TypeOfName.GetNameFromType <Booking>(), GenericError.FORBIDDEN_RESOURCE_OR_DOES_NO_EXIST);
                throw new ManahostValidationException(validationDictionnary);
            }
            HomeConfigRepository.includes.Add("DefaultMailConfig");
            hc = HomeConfigRepository.GetHomeConfigById(b.HomeId, currentClient.Id);
            if (!((BookingStepBookingValidation)validation).MailStepValidation(validationDictionnary, currentClient, hc, b, model, param))
            {
                throw new ManahostValidationException(validationDictionnary);
            }
            if (b.CurrentStep.MailTemplate == null)
            {
                validationDictionnary.AddModelError("CurrentStep.MailTemplate", GenericError.CANNOT_BE_NULL_OR_EMPTY);
                throw new ManahostValidationException(validationDictionnary);
            }
            body            = DocumentRepository.GetDocumentById(b.CurrentStep.MailTemplate.Id, currentClient.Id);
            listAttachments = b.CurrentStep.Documents;
            if (hc.DefaultMailConfig != null)
            {
                SendMailUsingCustomMailAccount(hc.DefaultMailConfig, b, log, model.Password,
                                               GetMailBody(body, b.Home), MailUtils.GetAttachments(listAttachments, b.Home));
            }
            else
            {
                SendMailUsingManahostMailAccount(b, log, GetMailBody(body, b.Home), MailUtils.GetAttachments(listAttachments, b.Home));
            }
            repo.Add <MailLog>(log);
            repo.Update(b);
            repo.Save();
            return(log);
        }
 public void Init()
 {
     ctx = EFContext.CreateContext();
     repo = new BookingStepBookingRepository(ctx);
     BookingStepConfig tmpconfig = new BookingStepConfig()
     {
         Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
         Title = "EFTest"
     };
     entity = new BookingStepBooking()
     {
         Booking = new Booking()
         {
             Comment = "I am a comment",
             DateArrival = DateTime.Now.AddYears(4),
             DateCreation = DateTime.Now,
             DateDeparture = DateTime.Now.AddYears(8),
             DateDesiredPayment = DateTime.Now.AddYears(1).AddMonths(10),
             DateModification = DateTime.Now,
             DateValidation = DateTime.Now.AddMonths(18),
             Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
             IsOnline = false,
             IsSatisfactionSended = false,
             People = new People()
             {
                 AcceptMailing = true,
                 Addr = "4 place kleber",
                 City = "Strasbourg",
                 Civility = "Mr",
                 Comment = "A mis le feu à la chambre",
                 Country = "FRANCE",
                 DateBirth = DateTime.Now,
                 DateCreation = DateTime.Now,
                 Email = "*****@*****.**",
                 Firstname = "CHAABANE",
                 Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
                 Lastname = "Jalal",
                 Mark = 0,
                 Phone1 = "0600000000",
                 Phone2 = null,
                 State = null,
                 ZipCode = "67000",
                 Hide = false,
             },
             TotalPeople = 4
         },
         BookingStepConfig = tmpconfig,
         CurrentStep = new BookingStep()
         {
             Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
             BookingStepConfig = tmpconfig,
             Title = "EFTest",
             BookingValidated = true,
             BookingArchived = false
         },
         Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
         DateCurrentStepChanged = DateTime.Now,
         MailSent = 0,
         Canceled = false
     };
 }
Ejemplo n.º 4
0
        public void Init()
        {
            ctx  = EFContext.CreateContext();
            repo = new BookingStepBookingRepository(ctx);
            BookingStepConfig tmpconfig = new BookingStepConfig()
            {
                Home  = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
                Title = "EFTest"
            };

            entity = new BookingStepBooking()
            {
                Booking = new Booking()
                {
                    Comment            = "I am a comment",
                    DateArrival        = DateTime.Now.AddYears(4),
                    DateCreation       = DateTime.Now,
                    DateDeparture      = DateTime.Now.AddYears(8),
                    DateDesiredPayment = DateTime.Now.AddYears(1).AddMonths(10),
                    DateModification   = DateTime.Now,
                    DateValidation     = DateTime.Now.AddMonths(18),
                    Home                 = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
                    IsOnline             = false,
                    IsSatisfactionSended = false,
                    People               = new People()
                    {
                        AcceptMailing = true,
                        Addr          = "4 place kleber",
                        City          = "Strasbourg",
                        Civility      = "Mr",
                        Comment       = "A mis le feu à la chambre",
                        Country       = "FRANCE",
                        DateBirth     = DateTime.Now,
                        DateCreation  = DateTime.Now,
                        Email         = "*****@*****.**",
                        Firstname     = "CHAABANE",
                        Home          = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
                        Lastname      = "Jalal",
                        Mark          = 0,
                        Phone1        = "0600000000",
                        Phone2        = null,
                        State         = null,
                        ZipCode       = "67000",
                        Hide          = false,
                    },
                    TotalPeople = 4
                },
                BookingStepConfig = tmpconfig,
                CurrentStep       = new BookingStep()
                {
                    Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
                    BookingStepConfig = tmpconfig,
                    Title             = "EFTest",
                    BookingValidated  = true,
                    BookingArchived   = false
                },
                Home = ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie"),
                DateCurrentStepChanged = DateTime.Now,
                MailSent = 0,
                Canceled = false
            };
        }