public async Task <IActionResult> Edit(ProgrammingTaskCategory model, Guid?categoryId = null)
        {
            // ReSharper disable once InvertIf
            if (ModelState.IsValid)
            {
                /*
                 * Create a new tasks category
                 */

                if (categoryId == null)
                {
                    var createdCategory = new ProgrammingTaskCategory
                    {
                        DisplayName = model.DisplayName,
                        Description = model.Description
                    };

                    await _databaseContext.ProgrammingTaskCategories.AddAsync(createdCategory);

                    await _databaseContext.SaveChangesAsync();

                    return(RedirectToAction("Categories", "ProgrammingTasksArchive", new { area = "TasksArchive" }));
                }

                /*
                 * Update existing tasks category
                 */

                if (!await CategoryExistsAsync(categoryId.Value))
                {
                    return(NotFound());
                }

                var modifiedCategory = await _databaseContext.ProgrammingTaskCategories
                                       .Where(c => c.Id == categoryId)
                                       .FirstAsync();

                modifiedCategory.DisplayName = model.DisplayName;
                modifiedCategory.Description = model.Description;

                _databaseContext.ProgrammingTaskCategories.Update(modifiedCategory);
                await _databaseContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Edit), new { categoryId }));
            }

            return(View(ViewsDirectoryPath + "Edit.cshtml", model));
        }
        public async Task <IActionResult> Edit(Guid?categoryId = null)
        {
            ProgrammingTaskCategory model = null;

            // ReSharper disable once InvertIf
            if (categoryId != null)
            {
                if (!await CategoryExistsAsync(categoryId.Value))
                {
                    return(NotFound());
                }

                model = await _databaseContext.ProgrammingTaskCategories
                        .Where(c => c.Id == categoryId)
                        .AsNoTracking()
                        .FirstAsync();
            }

            return(View(ViewsDirectoryPath + "Edit.cshtml", model));
        }