Esempio n. 1
0
        public ActionResult Detail(int id)
        {
            var prize     = _prizeService.GetById(id);
            var prizeForm = PrizeForm.FromPrize(prize);

            return(View(prizeForm));
        }
Esempio n. 2
0
        public async Task ExchangePoints(int prizeId, int beneficiaryId, string theme)
        {
            using (var trasactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    var beneficiary = _beneficiaryService.GetById(beneficiaryId);

                    var prize = _prizeService.GetById(prizeId);

                    if (prize.PointsNeeded > beneficiary.Points)
                    {
                        throw new ApplicationException("Puntos insuficientes");
                    }

                    PointsExchange pointsExchange = new PointsExchange();

                    pointsExchange.BeneficiaryId = beneficiary.Id;
                    pointsExchange.PrizeId       = prize.Id;
                    pointsExchange.PointsUsed    = prize.PointsNeeded;
                    pointsExchange.ExchangeDate  = _clock.Now;

                    Uow.PointsExchanges.Add(pointsExchange);

                    var      users       = _userService.GetUsersBeneficiaryAdmin();
                    string[] emailsAdmin = users.Select(u => u.Email).ToArray();
                    //users.RemoveAt(0);
                    //foreach (var userDto in users)
                    //{
                    //    emailsAdmin = string.Format("{0};{1}",emailsAdmin, userDto.Email);
                    //}

                    await _notificationService.SendPointsExchangeConfirmationEmail(prize, beneficiary, emailsAdmin, pointsExchange.ExchangeDate, theme);

                    await Uow.CommitAsync();

                    trasactionScope.Complete();
                }
                catch (Exception ex)
                {
                    trasactionScope.Dispose();
                    throw ex;
                }
            }
        }
Esempio n. 3
0
        public ActionResult Detail(int id)
        {
            var prize = _prizeService.GetById(id);

            return(View(prize));
        }