Exemplo n.º 1
0
        public async Task <IActionResult> EditEmpById(EmpModel empModel)
        {
            if (empModel.ProfilePhoto != null)
            {
                String folder = "images/Employees/";
                folder           += Guid.NewGuid().ToString() + "_" + empModel.ProfilePhoto.FileName;
                empModel.PhotoURL = "/" + folder;
                String serverFolder = Path.Combine(_webHostEnvironment.WebRootPath, folder);

                await empModel.ProfilePhoto.CopyToAsync(new FileStream(serverFolder, FileMode.Create));
            }
            bool success = await _empRepository.UpdateEmp(empModel);

            if (success == true)
            {
                return(RedirectToAction(nameof(EditEmp), new { isSucceess = true, empId = empModel.EmpId }));
            }
            ViewBag.Jobs = new SelectList(await _jobRepository.GetJobs(), "JobId", "JobName");
            return(View());
        }
Exemplo n.º 2
0
 public void Put([FromBody] Emp emp)
 {
     _empRepository.UpdateEmp(emp);
 }