public async Task <IActionResult> PutEmployeeInfo(string id, EmployeeInfo employeeInfo) { if (id != employeeInfo.Empid) { return(BadRequest()); } _context.Entry(employeeInfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployee(int id, Employee employee) { employee.Id = id; _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployee([FromRoute] int id, [FromBody] Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Name,JobDescription,Number,Department,HourlyPay,Bonus,EmployeeTypeId")] EmployeeSystemDesignPatterns.Models.EmployeeModels.Employee employee) { if (ModelState.IsValid) { //For Simple Factory //EmployeeManagerFactory empFactory = new EmployeeManagerFactory(); //var empManager = empFactory.createFactory(employee.EmployeeTypeId); //employee.Bonus = empManager.getBonus(); //employee.HourlyPay = empManager.getPay(); //For Factory Method Design Pattern EmployeeManagerFactory empFactory = new EmployeeManagerFactory(); var baseEmployeeFactory = empFactory.createEmployeeTypeFactory(employee); baseEmployeeFactory.ComputeAllowances(); //For Abstract Factory Method Pattern EmployeeSystemFactory employeeSystemFactory = new EmployeeSystemFactory(); var createdFactory = employeeSystemFactory.Create(employee); EmployeeSystemManager manager = new EmployeeSystemManager(createdFactory); employee.ComputerDetails = manager.getSystemDetails(); _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } // ViewBag.EmployeeTypeID = new SelectList(_context.EmployeeTypes, "EmployeeTypesId", "EmpType", employee.EmployeeTypeId); return(View(employee)); //return View(employee); }
public async Task <ActionResult <Department> > PostDepartment(Department department) { _context.Departments.Add(department); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDepartment", new { id = department.DepartmentId }, department)); }
public async Task <IActionResult> PutDepartment(int id, Department department) { if (id != department.DepartmentId) { return(BadRequest()); } _context.Entry(department).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutECandidate(int id, ECandidate eCandidate) { if (id != eCandidate.Id) { return(BadRequest()); } _context.Entry(eCandidate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ECandidateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task InsertEmployee(TblEmployee entity) { _context.Employees.Add(entity); await _context.SaveChangesAsync(); _cache.Remove(TBLEMPLOYEEKEY); }
public async Task <DTO.Employees.Employee> Add(DTO.Employees.Employee employee) { var emp = Mapper.Map <Entities.Employees.Employee>(employee); this.dbContext.Employees.Add(emp); await dbContext.SaveChangesAsync(); return(Mapper.Map <DTO.Employees.Employee>(this.dbContext.Employees.OrderByDescending(x => x.Id).FirstOrDefault())); }
public async Task <T> Create(T entity) { EntityEntry dbEntityEntry = employeeDBContext.Entry(entity); var response = await employeeDBContext.Set <T>().AddAsync(entity); await employeeDBContext.SaveChangesAsync(); return(response.Entity); }
public async Task <IActionResult> Create([Bind("TeacherId,TeacherName,TeacherDept")] TeacherDb teacherDb) { if (ModelState.IsValid) { _context.Add(teacherDb); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teacherDb)); }
public async Task <IActionResult> Create([Bind("Id,EmpName,EmpAddress,ContactNum")] TblEmp tblEmp) { if (ModelState.IsValid) { _context.Add(tblEmp); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tblEmp)); }
public async Task <IActionResult> Create([Bind("EmpId,FirstName,LastName,Designation,Position,Office")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create(EmployeeModel _empModel) { if (ModelState.IsValid) { _db.Add(_empModel); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(_empModel)); }
public async Task <IActionResult> Create([Bind("EmployeeId,FirstName,LastName,Gender,PhoneNumber,EmailID,PostalCode,Retired,StateName")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,NickName,Designation,Dept")] Employee employee) { if (ModelState.IsValid) { db.Employees.Add(employee); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(employee)); }
public async Task <ActionResult> Create([Bind(Include = "EmployeeTypeId,EmployeeTyp,Desc,Is_Actv,Is_Del,Crtd_by,Crtd_ts,Mod_by,Mod_ts,RowVersion")] EmployeeType employeeType) { if (ModelState.IsValid) { db.EmployeeTypes.Add(employeeType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(employeeType)); }
public async Task <ActionResult> Create([Bind(Include = "DesignationID,Designation_Name,Designation_code,Is_Actv,Is_Del,Crtd_by,Crtd_ts,Mod_by,Mod_ts,RowVersion,DepartmentID")] Designation designation) { if (ModelState.IsValid) { db.Designations.Add(designation); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Department_Name", designation.DepartmentID); return(View(designation)); }
public async Task <IActionResult> Create([Bind("EmployeeId,Name,Surname,Birthday,GenderId,PositionId")] Employees employees) { if (ModelState.IsValid) { _context.Add(employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GenderId"] = new SelectList(_context.MasterGender, "GenderId", "GenderName", employees.GenderId); ViewData["PositionId"] = new SelectList(_context.MasterPosition, "PositionId", "PositionName", employees.PositionId); return(View(employees)); }
public async Task <ActionResult> Create([Bind(Include = "Holidayid,HolidayName,Desc,Year,RowVersion,OrganizationID")] Holiday holiday) { if (ModelState.IsValid) { db.Holidays.Add(holiday); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.OrganizationID = new SelectList(db.Organizations, "OrganizationID", "Organization_Name", holiday.OrganizationID); return(View(holiday)); }
public async Task <ActionResult <EmployeeDTO> > Post(Employee employee) { try { _context.Employees.Add(employee); await _context.SaveChangesAsync(); } catch (Exception ex) { return(Problem(ex.Message, ex.StackTrace)); } return(Content("Created Successfully...")); }
public async Task <ActionResult> Create([Bind(Include = "EmployeeID,Employee_Name,Employee_Code,Email,Date_Of_Birth,Address,Contact_No,Emergency_Contact_No,Qualifications,Is_Actv,Is_Del,Crtd_by,Crtd_ts,Mod_by,Mod_ts,RowVersion,EmployeeTypeId,DesignationId")] Employee employee) { if (ModelState.IsValid) { db.Employees.Add(employee); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.DesignationId = new SelectList(db.Designations, "DesignationID", "Designation_Name", employee.DesignationId); ViewBag.EmployeeTypeId = new SelectList(db.EmployeeTypes, "EmployeeTypeId", "EmployeeTyp", employee.EmployeeTypeId); return(View(employee)); }
public async Task <Employee> InsertEmployeeAsync(Employee employee) { _Context.Add(employee); try { await _Context.SaveChangesAsync(); } catch (System.Exception exp) { _Logger.LogError($"Error in {nameof(InsertEmployeeAsync)}: " + exp.Message); } return(employee); }
public async Task InsertEmployee(Employee employee) { using (EmployeeDBContext dbContext = new EmployeeDBContext()) { await dbContext.Employees.AddAsync(employee); await dbContext.SaveChangesAsync(); } }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,MiddleName,FullName,Salaray,AddressId,Gender")] Employee employee) { //if (ModelState.IsValid) //{ try { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { logger.LogException(ex.Message); // throw; } //} return(View(employee)); }
public async Task <IActionResult> PutEmployeeModel(int id, [FromForm] EmployeeModel employeeModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employeeModel.EmployeeId) { return(BadRequest()); } if (employeeModel.ImageFile != null) { DeleteImage(employeeModel.ImageName); employeeModel.ImageName = await SaveImage(employeeModel.ImageFile); } _context.Entry(employeeModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Delete Employee By Id /// </summary> /// <param name="employeeId"></param> /// <returns></returns> public EmployeeModels DeleteEmployee(int employeeId) { try { EmployeeModels deleteEmployee = employeeContext.EmployeeTable.Find(employeeId); if (deleteEmployee != null) { employeeContext.EmployeeTable.Remove(deleteEmployee); employeeContext.SaveChangesAsync(); return(deleteEmployee); } return(null); } catch (Exception e) { throw new Exception("Error While Deleting Employee" + e.Message); } }
public async Task <int> CompleteAsync() { return(await dbContext.SaveChangesAsync()); }
public async Task <int> Save() { return(await _context.SaveChangesAsync()); }
public async Task <int> Add(Employee employee) { _ctx.Employees.Add(employee); return(await _ctx.SaveChangesAsync()); }