public async Task <IActionResult> Put(int id, [FromBody] EmployeeViewDto item) { if (item == null) { return(BadRequest(ModelState)); } try { var result = await _repository.UpdateAsync(id, _mapper.Map <Employee>(item)); if (result) { return(StatusCode(200)); } else { return(StatusCode(500)); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(StatusCode(500, ModelState)); } }
public ActionResult ViewEmployee(string Id) { int employeeId = DecryptQueryString(Id); if (employeeId <= 0) { return(RedirectToAction("EmployeeLookUp")); } EmployeeViewDto employeeViewDto = _employeeService.GetViewById(employeeId); return(View(employeeViewDto)); }
public EmployeeViewDto GetViewById(int employeeId) { List <uspEmployeeGetViewByID_Result> lstuspEmployeeGetViewByID_Result = _dbContext.uspEmployeeGetViewByID(employeeId).ToList(); EmployeeViewDto employeeViewDto = new EmployeeViewDto(); employeeViewDto = Mapper.Map <uspEmployeeGetViewByID_Result, EmployeeViewDto>(lstuspEmployeeGetViewByID_Result.FirstOrDefault()); List <EmployeeKYCDto> lstEmployeeKYCDto = new List <EmployeeKYCDto>(); List <uspEmployeeKYCGetViewByID_Result> lstuspEmployeeKYCGetViewByID_Result = _dbContext.uspEmployeeKYCGetViewByID(employeeId).ToList(); foreach (var Item in lstuspEmployeeKYCGetViewByID_Result) { EmployeeKYCDto objEmployeeKYCDto = new EmployeeKYCDto(); objEmployeeKYCDto.EmployeeID = Item.EmployeeID; objEmployeeKYCDto.KYCNumber = Item.KYCNumber; objEmployeeKYCDto.FileName = Item.FileName; lstEmployeeKYCDto.Add(objEmployeeKYCDto); } employeeViewDto.EmployeeKYC = lstEmployeeKYCDto; return(employeeViewDto); }