public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,StartingDate,StartTime,EndingDate,EndTime,SpecialEvents,SpecialShabassos,Months,Parshios,LifeEvents,EventDescription")] CreateYearlyEventsViewModel createYearlyEventsViewModel)
        {
            if (id != createYearlyEventsViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(createYearlyEventsViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CreateYearlyEventsViewModelExists(createYearlyEventsViewModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", createYearlyEventsViewModel.UserId);
            return(View(createYearlyEventsViewModel));
        }
Exemplo n.º 2
0
        // GET: YearlyEvents/Create
        public IActionResult Create()
        {
            CreateYearlyEventsViewModel createYearlyEventsViewModel =
                new CreateYearlyEventsViewModel();

            return(View(createYearlyEventsViewModel));
        }
        public async Task <IActionResult> Create([Bind("Id,UserId,StartingDate,StartTime,EndingDate,EndTime,SpecialEvents,SpecialShabassos,Months,Parshios,LifeEvents,EventDescription")] CreateYearlyEventsViewModel createYearlyEventsViewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(createYearlyEventsViewModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", createYearlyEventsViewModel.UserId);
            return(View(createYearlyEventsViewModel));
        }