public DBSeeker(EmployeeContext dbContext) { // Adding Stationery Data Project pro1 = new Project(); pro1.projectName = "Project1"; Project pro2 = new Project(); pro2.projectName = "Project2"; Project pro3 = new Project(); pro3.projectName = "Project3"; dbContext.Add(pro1); dbContext.Add(pro2); dbContext.Add(pro3); /*EmpTask et1 = new EmpTask(); * et1.Task_Name = "Task001"; * et1.Task_Description = "Desc001"; * et1.Client_Name = "Client001"; * et1.project = pro1; * * dbContext.Add(et1);*/ // Saving Changes dbContext.SaveChanges(); }
public async Task <IActionResult> CreateProject([Bind("ProjectId,ProjectName")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Projects))); } return(View()); }
public async Task <IActionResult> Create([Bind("FirstName,LastName,PhoneNumber,Email,Address,DesignationId,designation")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("EmployeeId,FullName,Phone,EmpCode,position,OfficeLocation,Active")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> CreateorUpdate([Bind("EmployeeId,FullName,EmpCode,Designation,OfficeLocations")] Employee employee) { try { _logger.LogInformation("Log message in the CreateorUpdate(EmployeeId=" + employee.EmployeeId + "FullName=" + employee.FullName + " EmpCode" + employee.EmpCode + ") method"); //check whether modelstate is valid if (ModelState.IsValid) { if (employee.EmployeeId == 0) { _context.Add(employee); } else { _context.Update(employee); } await _context.SaveChangesAsync(); _logger.LogInformation("Log message end in CreateorUpdate()"); return(RedirectToAction(nameof(Index))); } return(View(employee)); } catch (Exception ex) { _logger.LogError($"Something went wrong: {ex}"); throw; } }
// Create New Employee public string AddEmployee(Employee employee) { _dbContext.Add(employee); _dbContext.SaveChanges(); return("New Employee Record Created Successfully"); }
//[ValidateAntiForgeryToken] public async Task <IActionResult> AddOrEdit([Bind("EmployeeId,FullName,EmpCode,Position,OfficeLocation")] Employee employee) { if (ModelState.IsValid) { try { if (employee.EmployeeId == 0) { _context.Add(employee); } else { _context.Update(employee); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { _logger.LogError(ex.Message); return(View()); } } return(View(employee)); }
public Employee Create(string firstName, string lastName, string address, string homePhone, string cellPhone) { var employee = employeeContext.Add(new Employee { FirstName = firstName, LastName = lastName, Address = address, HomePhone = homePhone, CellPhone = cellPhone }); employeeContext.SaveChanges(); return(employee.Entity); }
public async Task<IActionResult> Create([Bind("EmployeeId,EmployeeNum,EmployeeDate,TerminatedDate,PersonId,FirstName,LastName,BirthDate")] EmployeeViewModel employeeViewModel) { if (ModelState.IsValid) { _context.Add(employeeViewModel); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(employeeViewModel); }
public async Task <IActionResult> Modify([Bind("EmployeeId,FullName,EmpCod,Position,OfficeLocation")] Employee employee) { if (ModelState.IsValid) { if (employee.EmployeeId == 0) { _context.Add(employee); } else { _context.Update(employee); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("FirstName, LastName, DateOfBirth, Sex, MaritalStatus, Password, ConfirmPassword, NumberOfChildren")] Employee employee) { using (var context = new EmployeeContext()) { context.Add(employee); await context.SaveChangesAsync(); return(RedirectToAction("Index")); } }
public IActionResult Create(Employee model) { if (!ModelState.IsValid) { return(View(model)); } context.Add(model); context.SaveChanges(); return(RedirectToAction("index")); }
public async Task <IActionResult> Create([Bind("ID,Type,Address,Zipcode")] Location location) { if (ModelState.IsValid) { _context.Add(location); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(location)); }
public async Task <IActionResult> Create([Bind("EmployeeId,Name,DepartmentId,Salary,Gender")] EmployeeTb employeeTb) { if (ModelState.IsValid) { _context.Add(employeeTb); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employeeTb)); }
public async Task <IActionResult> Create([Bind("HobbyID,HobbyName")] Hobby hobby) { if (ModelState.IsValid) { _context.Add(hobby); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hobby)); }
public async Task <IActionResult> Create([Bind("ProductId,ProductName,Qty,Price")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("SkillID,Title")] Skill skill) { if (ModelState.IsValid) { _context.Add(skill); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(skill)); }
public async Task <IActionResult> Create([Bind("Id,FullName,Email,Salary")] EmployeeModel employeeModel) { if (ModelState.IsValid) { _context.Add(employeeModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employeeModel)); }
public async Task <IActionResult> Create([Bind("EMPID,BIRTHDATE,LASTNAME,FIRSTNAME,PHONE")] EmployeeData employeeData) { if (ModelState.IsValid) { _context.Add(employeeData); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employeeData)); }
public async Task <IActionResult> Create([Bind("EmployeeID,Name,Empcode,Position,Location")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create(Employee employee) { if (ModelState.IsValid) { _employeeContext.Add(employee); await _employeeContext.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("EmployeeID,EmployeeName,EmployeeSurname,EmployeeDaireBaskanligi,EmployeeJob")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("Id,Name,Discription,Category,TelNumber,ImgRes,Price,Owner")] Employees employees) { if (ModelState.IsValid) { _context.Add(employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(Redirect("/Employees/IndexClient")); }
public async Task <IActionResult> AddOrEdit([Bind("EmployeeId,FullName,EmpCode,Position,OfficeLocation")] Employees employees) { if (ModelState.IsValid) { _context.Add(employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employees)); }
public async Task <IActionResult> Create([Bind("EmployeeID,FirstName,LastName,CrewPosition")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(employee)); }
public long CreateEmployee(string name) { Employee employee = new Employee(name); using (EmployeeContext employeeContext = new EmployeeContext()) { employeeContext.Add(employee); employeeContext.SaveChanges(); } return(employee.Id); }
public async Task <IActionResult> Create([Bind("DepartmentId,Title,Credits")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Create([Bind("ID,LastName,FirstMidName,StartDate,EndDate,Address,EmailAddress,PhoneNumber,EmployeeStatus,Department,Shift,Manager,ImageFileName,FavoriteColor")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,Phone")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("TaskId,Text,Completed,EmployeeId")] Models.Task task) { if (ModelState.IsValid) { _context.Add(task); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { id = task.EmployeeId })); } return(View(task)); }