public async Task <IActionResult> Create([Bind("CasualEmployeeId,CasualRoleId,Name,Surname,Email,CurrentHourlyRateInZar,IsEnabled")] CasualEmployees casualEmployees, IFormFile image) { if (ModelState.IsValid) { if (image != null) { if (image.Length > 0) { byte[] p1 = null; using (var fs1 = image.OpenReadStream()) using (var ms1 = new MemoryStream()) { fs1.CopyTo(ms1); p1 = ms1.ToArray(); } casualEmployees.ProfilePicture = p1; } } var role = _context.CasualRoles.FirstOrDefault(x => x.CasualRoleId == casualEmployees.CasualRoleId); casualEmployees.CurrentHourlyRateInZar = role.HourlyRateInZar; _context.Add(casualEmployees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CasualRoleId"] = new SelectList(_context.CasualRoles, "CasualRoleId", "CasualRole", casualEmployees.CasualRoleId); return(View(casualEmployees)); }
public async Task <IActionResult> Create([Bind("CasualRoleId,CasualRole,HourlyRateInZar,IsEnabled")] CasualRoles casualRoles) { if (ModelState.IsValid) { _context.Add(casualRoles); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(casualRoles)); }
public async Task <IActionResult> Create([Bind("CasualTaskId,CasualTask,TimeEstiamteInHours,DateStarted,DateCompleted,IsEnabled")] CasualTasks casualTasks) { if (ModelState.IsValid) { _context.Add(casualTasks); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(casualTasks)); }