Ejemplo n.º 1
0
        public async Task <bool> CreateEmployee(Employee employee)
        {
            employee.Id = Guid.NewGuid().ToString();
            _dbContext.Add(employee);
            try
            {
                await _dbContext.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Employees.Add(Employee);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }