public virtual async Task <T> Create(T obj) { _context.Add(obj); await _context.SaveChangesAsync(); return(obj); }
public async Task <IActionResult> Edit(long id, string familyName, string name, string surname, IFormFile image, DateTime birthDate) { //check if ID have value on form // get staffMember HumanResourcesModel staffMember = await _context.StaffMember.FindAsync(id); //get path to image string path = await UploadImg(image); if (staffMember != null) { // update all staff's fields staffMember.FamilyName = familyName; staffMember.Name = name; staffMember.Surname = surname; staffMember.BirthDate = birthDate; staffMember.Image = path; //update and save staffmember in database _context.StaffMember.Update(staffMember); await _context.SaveChangesAsync(); return(RedirectToAction("StaffList")); } return(NotFound()); }
public async Task <IActionResult> Create([Bind("EmployeeId,FirstName,LastName,DateBirthday,Inn")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <int> AddEmployee(Employees Employee) { if (db != null) { await db.Employees.AddAsync(Employee); await db.SaveChangesAsync(); return(Employee.EmployeeId); } return(0); }
public async Task <int> AddDepartment(Departments department) { if (db != null) { await db.Departments.AddAsync(department); await db.SaveChangesAsync(); return(department.DepartmentId); } return(0); }
public async Task <int> AddJob(Jobs job) { if (db != null) { await db.Jobs.AddAsync(job); await db.SaveChangesAsync(); return(job.JobId); } return(0); }
public virtual async Task <int> Insert(T obj) { _dbSet.Add(obj); return(await _context.SaveChangesAsync()); }
public async Task Add(Employee dbItem) { await _context.Employee.AddAsync(dbItem); await _context.SaveChangesAsync(); }