Esempio n. 1
0
        public void Edit(Auction model)
        {
            double currencyRate = CurrencyService.GetCurrencyRate();

            model.PriceUSDSearch = (model.CurrencyID == 1) ? model.StartPrice : (int)(model.StartPrice / currencyRate);
            model.PriceUAHSearch = (model.CurrencyID == 2) ? model.StartPrice : (int)(model.StartPrice * currencyRate);

            this._repository.Update(model);
            Save();

            AuctionIndexService.UpdateIndex(model);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void Delete(Auction model)
        {
            List <AuctionPhoto> photos = model.AuctionPhotoes.ToList();

            foreach (var item in photos)
            {
                AuctionPhotoService.Delete(item.ID);
            }

            List <AuctionBid> bids = model.AuctionBids.ToList();

            foreach (var item in bids)
            {
                AuctionBidService.Delete(item);
            }

            AuctionIndexService.DeleteFromIndex(model);

            this._repository.Delete(model);
            Save();
        }