コード例 #1
0
 public ActionResult Subscriptions(int?kundeId)
 {
     if (PauseSecurity.IsInRole(RoleTypes.Customer))
     {
         kundeId = PauseSecurity.GetUserId();
     }
     if (kundeId.HasValue)
     {
         return(View(GetCustomerSubscriptions(kundeId.Value)));
     }
     else
     {
         return(View(new List <Abonnementer>()));
     }
 }
コード例 #2
0
 public ActionResult Index()
 {
     if (PauseSecurity.IsAuthenticated)
     {
         var model = new LeveringModel()
         {
             StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(10)
         };
         if (PauseSecurity.IsInRole(RoleTypes.Customer))
         {
             model.KundeId = PauseSecurity.GetUserId();
             model.CustomerDeliveryAdresses = GetCustomerDeliveryAdresses(model.KundeId, model.StartDate, model.EndDate);
         }
         return(View("Levering", model));
     }
     return(View());
 }
コード例 #3
0
        public ActionResult Index(LeveringModel model)
        {
            // Change KundeId if user is customer
            if (PauseSecurity.IsInRole(RoleTypes.Customer))
            {
                model.KundeId = PauseSecurity.GetUserId();
            }
            if (model.KundeId <= 0)
            {
                ModelState.AddModelError("KundeName", "Kunde eksisterer ikke.");
            }
            else if (model.EndDate < model.StartDate)
            {
                ModelState.AddModelError("EndDate", "Slutdato bør ikke være mindre Startdato.");
            }
            if (!ModelState.IsValid)
            {
                return(View("Levering", model));
            }

            model.CustomerDeliveryAdresses = GetCustomerDeliveryAdresses(model.KundeId, model.StartDate, model.EndDate);

            return(View("Levering", model));
        }