public async Task <ActionResult> Edit(int id, ExaminationPlanEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }

            var plan = await this.examManager.FindByIdAsync(id);

            if (plan == null)
            {
                return(HttpNotFound());
            }
            plan.Title   = model.Title;
            plan.Address = model.Address;
            plan.AttendanceConfirmationExpiresAt = model.AttendanceConfirmationExpiresAt;
            plan.Notes = model.Notes;
            try
            {
                await this.examManager.UpdateAsync(plan);

                return(RedirectToAction("Detail", new { id }));
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
        public async Task <ActionResult> Create(ExaminationPlanEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }

            var plan = new ExaminationPlan(model.Title, model.Address)
            {
                AttendanceConfirmationExpiresAt = model.AttendanceConfirmationExpiresAt,
                Notes = model.Notes,
            };

            try
            {
                await this.examManager.CreateAsync(plan);

                return(RedirectToAction("Detail", new { id = plan.Id }));
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
        public async Task <ActionResult> Edit(int id)
        {
            var plan = await this.examManager.FindByIdAsync(id);

            if (plan == null)
            {
                return(HttpNotFound());
            }

            var model = new ExaminationPlanEditViewModel()
            {
                Title   = plan.Title,
                Address = plan.Address,
                AttendanceConfirmationExpiresAt = plan.AttendanceConfirmationExpiresAt,
                Notes = plan.Notes,
            };

            return(View(model));
        }
        public ActionResult Create()
        {
            var model = new ExaminationPlanEditViewModel();

            return(View(model));
        }