Exemplo n.º 1
0
        public void Create(Auction model)
        {
            this._repository.Add(model);
            Save();

            AuctionIndexService.AddToIndex(model);

            int    eligiblePeriodInMinutes = 0;
            string tmp = $"{XCarsConfiguration.XMinutesAuctionFinishEmailEligiblePeriod}";

            int.TryParse(tmp, out eligiblePeriodInMinutes);

            ScheduledEmail email = new ScheduledEmail()
            {
                DateScheduled = DateTime.Now,
                DateDue       = model.Deadline,
                //StatusID = 1,
                To           = model.Auto.User.Email,
                Subject      = "Subject1",
                Body         = "Text1",
                ObjectTypeID = 2,
                ObjectID     = model.ID
            };

            email.DateEligible = email.DateDue.AddMinutes(eligiblePeriodInMinutes);
            ScheduledEmailService.Create(email);

            int minutes = 0;

            tmp = $"{XCarsConfiguration.XMinutesRemaingToAuctionDeadline}";
            int.TryParse(tmp, out minutes);

            eligiblePeriodInMinutes = 0;
            tmp = $"{XCarsConfiguration.XMinutesRemainingAuctionFinishEmailEligiblePeriod}";
            int.TryParse(tmp, out eligiblePeriodInMinutes);

            ScheduledEmail email2 = new ScheduledEmail()
            {
                DateScheduled = DateTime.Now,
                DateDue       = model.Deadline.AddMinutes(-1 * minutes),
                //StatusID = 1,
                To           = model.Auto.User.Email,
                Subject      = "Subject1",
                Body         = "Text1",
                ObjectTypeID = 3,
                ObjectID     = model.ID
            };

            email2.DateEligible = email2.DateDue.AddMinutes(eligiblePeriodInMinutes);
            ScheduledEmailService.Create(email2);
        }
Exemplo n.º 2
0
        public void Finish(Auction model, bool finishedManually = false)
        {
            model.StatusID = 3;
            Edit(model);

            List <AuctionFavorite> favs = model.AuctionFavorites.ToList();

            for (int i = 0; i < favs.Count; i++)
            {
                AuctionFavoriteService.Delete(favs[i]);
            }

            if (finishedManually)
            {
                ScheduledEmailService.CancelScheduledEmails(2, model.ID);
                ScheduledEmailService.CancelScheduledEmails(3, model.ID);
            }
        }
Exemplo n.º 3
0
        public void MoveToArchives(Auto model, bool movedManually = false)
        {
            model.StatusID = 3;
            model.Top      = 0;

            List <AutoFavorite> favs = model.AutoFavorites.ToList();

            for (int i = 0; i < favs.Count; i++)
            {
                AutoFavoriteService.Delete(favs[i]);
            }

            if (movedManually)
            {
                //cancel scheduled emails concerning this auto
                ScheduledEmailService.CancelScheduledEmails(4, model.ID);
            }

            Edit(model);
        }