Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,DayOfWeek,Description,CreatedById")] Hollyday hollyday)
        {
            if (id != hollyday.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hollyday);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HollydayExists(hollyday.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CreatedById"] = new SelectList(_context.Employees, "Id", "Id", hollyday.CreatedById);
            return(View(hollyday));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,Date,DayOfWeek,Description,CreatedById")] Hollyday hollyday)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hollyday);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CreatedById"] = new SelectList(_context.Employees, "Id", "Id", hollyday.CreatedById);
            return(View(hollyday));
        }