Beispiel #1
0
        public async Task UpdateAsync(int id, EditPlannedTaskInputModel input)
        {
            var plannedTasks = this.plannedTasksRepository.All().FirstOrDefault(x => x.Id == id);

            plannedTasks.Title       = input.Title;
            plannedTasks.Date        = input.Date;
            plannedTasks.StartTime   = input.StartTime;
            plannedTasks.EndTime     = input.EndTime;
            plannedTasks.CategoryId  = input.CategoryId;
            plannedTasks.Description = input.Description;
            plannedTasks.IsDone      = input.IsDone;
            await this.plannedTasksRepository.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, EditPlannedTaskInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                input.CategoriesItems = this.categoriesService.GetAllAsKeyValuePairs();
                return(this.View(input));
            }

            await this.plannedTasksService.UpdateAsync(id, input);

            if (input == null)
            {
                return(this.RedirectToAction("NotFoundError", "Error"));
            }

            return(this.Redirect("/PlannedTasks/Schedule"));
        }