Beispiel #1
0
        public async Task <IActionResult> OnPostAsync(string performanceId, string categoryId)
        {
            if (!User.IsInRole(Constants.Bookkeeper) && !User.IsInRole(Constants.Administrator))
            {
                return(NotFound());
            }

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

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

            PerformanceCategories = await Context.PerformanceCategories.FindAsync(performanceId, categoryId);

            if (PerformanceCategories != null)
            {
                Context.PerformanceCategories.Remove(PerformanceCategories);
                await Context.SaveChangesAsync();
            }

            return(Redirect("./IndexCategories?id=" + PerformanceCategories.PerformanceId));
        }
Beispiel #2
0
        public async Task <IActionResult> OnGetAsync(string performanceId, string categoryId)
        {
            if (!User.IsInRole(Constants.Bookkeeper) && !User.IsInRole(Constants.Administrator))
            {
                return(NotFound());
            }

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

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

            PerformanceCategories = await Context.PerformanceCategories
                                    .Include(p => p.Category)
                                    .Include(p => p.Performance).FirstOrDefaultAsync(m => m.PerformanceId == performanceId && m.CategoryId == categoryId);

            if (PerformanceCategories == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnGet(string id)
        {
            if (id == null)
            {
                return(Redirect("/Error"));
            }

            PerformanceId = id;

            PerformanceCategories = await Context.PerformanceCategories
                                    .Where(p => p.PerformanceId == id)
                                    .Include(p => p.Performance)
                                    .Include(p => p.Category).ToListAsync();

            PerformanceName = PerformanceCategories.FirstOrDefault().Performance.Name;

            return(Page());
        }