示例#1
0
        public async Task <IActionResult> OnGetAsync()
        {
            Couple = await GetAuthorizedCouple();

            if (Couple == null)
            {
                return(NotFound());
            }

            if (!Couple.Dinner.HasPrice)
            {
                return(Redirect(ModelPath.Get <Couples.EditCoupleModel>()));
            }

            var status = await Couple.UpdatePaymentStatus();

            if (status.Changed)
            {
                await Database.SaveChangesAsync();
            }

            PaymentStatus = status.NewStatus;

            return(Page());
        }
示例#2
0
        private async Task <IActionResult> ValidateLogin()
        {
            Couple couple = await Database.GetCoupleAsAdminAsync(Id.Value, AdminCode);

            if (couple == null)
            {
                ModelState.AddModelError("CustomError", "Incorrect Id / Password ");
                return(Page());
            }

            HttpContext.Session.SetInt32("Id", Id.Value);
            HttpContext.Session.SetString("AdminCode", AdminCode);

            RedirectUrl = HttpUtility.UrlDecode(RedirectUrl);

            if (string.IsNullOrEmpty(RedirectUrl))
            {
                if (couple.IsAdmin)
                {
                    RedirectUrl = ModelPath.Get <Management.EditDinnerModel>();
                }
                else
                {
                    RedirectUrl = ModelPath.Get <Couples.EditCoupleModel>();
                }
            }

            return(RedirectToPage(RedirectUrl));
        }
示例#3
0
        public async Task <IActionResult> OnGetAsync()
        {
            Couple = await GetAuthorizedCouple();

            if (Couple == null)
            {
                return(NotFound());
            }

            if (Couple.Validated)
            {
                return(Redirect(ModelPath.Get <Couples.EditCoupleModel>()));
            }

            return(Page());
        }
示例#4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // Strip seconds
            Dinner.Date             = Dinner.Date.SetTime(Dinner.Date.Hour, Dinner.Date.Minute, 0, 0);
            Dinner.SubscriptionStop = Dinner.SubscriptionStop.SetTime(Dinner.Date.Hour, Dinner.Date.Minute, 0, 0);

            // Dont allow negative prices
            Dinner.Price = Math.Max(Dinner.Price, 0.0);

            if (Dinner.Date < DateTime.Now.AddDays(Dinner.MIN_DAYS_IN_ADVANCE).SetTime(0, 0))
            {
                ModelState.AddModelError("Dinner.Date", $"Kies een datum minimaal { Dinner.MIN_DAYS_IN_ADVANCE } dagen in de toekomst.");
                return(Page());
            }

            if ((Dinner.Date - Dinner.SubscriptionStop).TotalHours < 24)
            {
                ModelState.AddModelError("Dinner.SubscriptionStop", "Kies een tijd minimaal 24 uur vσσr het diner.");
                return(Page());
            }

            if (Dinner.HasPrice && (string.IsNullOrWhiteSpace(Couple.IBAN)))
            {
                ModelState.AddModelError("Couple.IBAN", "Een bankrekening is verplicht als het evenement geld kost.");
                return(Page());
            }

            if (await Database.CreateDinnerAsync(Dinner, Couple) == null)
            {
                ModelState.AddModelError(nameof(Dinner), "Kan dinner nu niet aanmaken.");
                return(Page());
            }

            EmailServer.SendEmail(Couple.EmailAddress, "Nieuw dinner",
                                  $"Nieuw diner aangemaakt, code: <a href=\"{ ModelPath.GetAbsolutePathWithAuthorization<Management.EditDinnerModel>( Request.Host, Couple.ID, Couple.AdminCode )}\">Beheer</a>");

            return(Redirect(ModelPath.Get <AwaitEmailModel>()));
        }
示例#5
0
        public async Task <IActionResult> OnGetAsync()
        {
            Couple = await GetAuthorizedCouple();

            if (Couple == null)
            {
                return(NotFound());
            }

            if (Couple.Dinner.SubscriptionStop < DateTime.Now)
            {
                return(Redirect(ModelPath.Get <Management.OverviewModel>()));
            }

            // Load the dinner itself, including other couples
            await Database.GetDinnerAsync(Couple.Dinner.ID);

            return(Page());
        }
示例#6
0
        public async Task <IActionResult> OnPostAsync()
        {
            Couple = await GetAuthorizedCouple();

            if (Couple == null)
            {
                return(NotFound());
            }

            // IF HAS PAYED:
            // REFUND PAYMENT
#warning Payment

            Couple.PaymentId     = null;
            Couple.PaymentStatus = null;
            Couple.Validated     = false;
            await Database.SaveChangesAsync();

            return(Redirect(ModelPath.Get <Couples.SeeInvitationModel>()));
        }
示例#7
0
        private async Task <IActionResult> GetCoupleAsync()
        {
            Couple = await GetAuthorizedCouple();

            if (Couple == null)
            {
                return(NotFound());
            }

            if (Couple.Dinner.SubscriptionStop > DateTime.Now)
            {
                return(Redirect(ModelPath.Get <Management.EditDinnerModel>()));
            }

            if (Couple.Dinner.Date < DateTime.Now)
            {
                return(Redirect(ModelPath.Get <Setup.CreateDinnerModel>()));
            }

            await Database.GetDinnerAsync(Couple.Dinner.ID);

            return(null);
        }
示例#8
0
        public async Task <IActionResult> OnPostAsync(int?IdToRemove)
        {
            if (IdToRemove == null)
            {
                return(NotFound());
            }

            if (IdToRemove == AuthorizedID)
            {
                // Cannot remove self
                return(BadRequest());
            }

            Couple adminCouple = await GetAuthorizedCouple();

            if (adminCouple == null)
            {
                return(NotFound());
            }

            Couple = await Database.GetCoupleAsync(IdToRemove.Value);

            if (Couple == null)
            {
                return(NotFound());
            }

            if (Couple.Dinner.ID != adminCouple.Dinner.ID)
            {
                return(BadRequest());
            }

            await Database.RemoveCoupleAsync(IdToRemove.Value);

            return(Redirect(ModelPath.Get <Management.EditDinnerModel>()));
        }