public async Task <IActionResult> Create([Bind("DepartmentId,DepartmentName,DepartmentCode,ArrangeOrder")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Create([Bind("WorkerTypeId,WorkerTypeName,WorkerTypeCode,ArrangeOrder")] WorkerType workerType) { if (ModelState.IsValid) { _context.Add(workerType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(workerType)); }
public async Task <IActionResult> Create([Bind("GradeId,GradeName,GradeCode,ArrangeOrder")] Grade grade) { if (ModelState.IsValid) { _context.Add(grade); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(grade)); }
public async Task <IActionResult> Create([Bind("ShiftId,ShiftCode,ShiftName,ShiftTimeIn,ShiftTimeOut,TimeSpanz")] Shift shift) { if (ModelState.IsValid) { _context.Add(shift); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(shift)); }
public async Task <IActionResult> Create([Bind("Id,EmployeeId,Attendance,AttendanceTime")] AttendanceRegister attendanceRegister) { if (ModelState.IsValid) { _context.Add(attendanceRegister); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "FirstName", attendanceRegister.EmployeeId); return(View(attendanceRegister)); }
public async Task <IActionResult> Create([Bind("Id,EmployeePhoto,FirstName,MiddleName,LastName,FullName,Gender,PrimaryMobileNo,SecondaryMobileNo,AreaStdCode,PhoneNo,EmailId,Address1,Address2,Address3,City,District,Pin,PostOffice,PoliceStation,DepartmentId,GradeId,WorkerTypeId")] Employee employee, IFormFile EmployeePhoto) { var b = System.IO.File.ReadAllBytes(_varimg.randuserimgchooser(_hosting_environment.WebRootPath)); byte[] c = null; if (EmployeePhoto != null) { if (EmployeePhoto.Length > 0) //Convert Image to byte and save to database { using (var ms1 = new MemoryStream()) { await EmployeePhoto.CopyToAsync(ms1); c = ms1.ToArray(); ViewBag.photo = Convert.ToBase64String(c); } } } if (ModelState.IsValid) { if (!c.Equals(null)) { employee.EmployeePhoto = c; } _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentCode", employee.DepartmentId); ViewData["GradeId"] = new SelectList(_context.Grade, "GradeId", "GradeCode", employee.GradeId); ViewData["WorkerTypeId"] = new SelectList(_context.WorkerType, "WorkerTypeId", "WorkerTypeCode", employee.WorkerTypeId); return(View(employee)); }