Ejemplo n.º 1
0
        public async Task <IActionResult> Create([FromForm] EmployeeModel employeeModel)
        {
            employeeModel.ImageName = await SaveImage(employeeModel.ImageFile);

            await _context.Employees.AddAsync(employeeModel);

            await _context.SaveChangesAsync();

            return(Created("", employeeModel));
        }
        public async Task <IActionResult> Create([Bind("DepartmentId,Name")] DepartmentModel departmentModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(departmentModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(departmentModel));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("EmployeeId,FirstName,LastName,EmailAddress,PhoneNumber,DepartmentId")] EmployeeModel employeeModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employeeModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "Name", employeeModel.DepartmentId);
            return(View(employeeModel));
        }
        public static async Task AddPayment(this PaymentModel payment)
        {
            using (_db = new EmployeeAppContext(_options))
            {
                await _db.Payments.AddAsync(payment);

                await _db.SaveChangesAsync();
            }
        }
        public static async Task AddPosition(this PositionModel position)
        {
            using (_db = new EmployeeAppContext(_options))
            {
                await _db.Positions.AddAsync(position);

                await _db.SaveChangesAsync();
            }
        }
        public static async Task AddUnit(this UnitModel unit)
        {
            using (_db = new EmployeeAppContext(_options))
            {
                await _db.Units.AddAsync(unit);

                await _db.SaveChangesAsync();
            }
        }
        public static async Task AddEmployee(this EmployeeModel employee)
        {
            using (_db = new EmployeeAppContext(_options))
            {
                await _db.Employees.AddAsync(employee);

                await _db.SaveChangesAsync();
            }
        }
Ejemplo n.º 8
0
 public async Task SaveChangesAsync()
 {
     await _Context.SaveChangesAsync();
 }