Esempio n. 1
0
        public IActionResult Edit(EditAgendaIndexVM model)
        {
            var agenda = context.Agendas.Find(model.Id);

            if (agenda == null)
            {
                return(RedirectToAction(nameof(AgendaController.Index)));
            }

            agenda.Title    = model.Title;
            agenda.Deadline = model.Deadline;
            context.SaveChanges();

            return(RedirectToAction(nameof(AgendaController.Edit), model.Id));
        }
Esempio n. 2
0
        public IActionResult Edit(int id)
        {
            var agenda = agendaService.GetById(id);

            if (agenda == null)
            {
                return(RedirectToAction(nameof(AgendaController.Index)));
            }

            var model = new EditAgendaIndexVM
            {
                Id         = agenda.Id,
                Title      = agenda.Title,
                Deadline   = agenda.Deadline,
                Categories = categoryService.GetAllValues().ToList()
            };

            return(View(model));
        }