Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Date,Amount,Type,InstructorFK")] Event @event)
        {
            if (id != @event.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(@event.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstructorFK"] = new SelectList(_context.Instructors, "Id", "FullName", @event.InstructorFK);
            ViewData["Types"]        = TypeWorkoutService.GetTypes();
            return(View(@event));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Title,Date,Amount,Type,InstructorFK")] Event @event)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@event);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstructorFK"] = new SelectList(_context.Instructors, "Id", "FullName", @event.InstructorFK);
            ViewData["Types"]        = TypeWorkoutService.GetTypes();
            return(View(@event));
        }
Пример #3
0
        // GET: Events/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var @event = await _context.Events.FindAsync(id);

            if (@event == null)
            {
                return(NotFound());
            }
            ViewData["InstructorFK"] = new SelectList(_context.Instructors, "Id", "FullName", @event.InstructorFK);
            ViewData["Types"]        = TypeWorkoutService.GetTypes();
            return(View(@event));
        }
Пример #4
0
 // GET: Events/Create
 public IActionResult Create()
 {
     ViewData["InstructorFK"] = new SelectList(_context.Instructors, "Id", "FullName");
     ViewData["Types"]        = TypeWorkoutService.GetTypes();
     return(View());
 }