public async Task <IActionResult> Edit(Employee_Resignation employee_Resignation) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = "Invalid Model State"; return(BadRequest(objHelper)); } try { if (employee_ResignationRepository.Exists(employee_Resignation)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await employee_ResignationRepository.Update(employee_Resignation); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; return(Ok(objHelper)); } catch { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = "Get Unsuccessful"; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
public async Task Update(Employee_Resignation entity) { try { var vList = adbContext.employee_resignation.Where(x => x.Emp_Resignation_Id == entity.Emp_Resignation_Id && x.Emp_Id == entity.Emp_Id).FirstOrDefault(); if (vList != null) { vList.Emp_Id = entity.Emp_Id; vList.ResignationDate = entity.ResignationDate; vList.NoticePeriod = entity.NoticePeriod; vList.LeaveDate = entity.LeaveDate; vList.LeaveReason = entity.LeaveReason; vList.LastWorkingDate = entity.LastWorkingDate; vList.Notes = entity.Notes; vList.isActive = entity.isActive; vList.UpdatedBy = entity.UpdatedBy; vList.UpdatedOn = DateTime.Now; adbContext.employee_resignation.Update(vList); await Task.FromResult(adbContext.SaveChanges()); } else { throw new Exception("Data Not Available"); } } catch (Exception ex) { throw ex; } }
public async Task Insert(Employee_Resignation entity) { try { entity.AddedOn = DateTime.Now; adbContext.employee_resignation.Add(entity); await Task.FromResult(adbContext.SaveChanges()); } catch (Exception ex) { throw ex; } }
public bool Exists(Employee_Resignation entity) { try { int intCount = 0; if (entity.Emp_Resignation_Id > 0) //Update Validation { intCount = adbContext.employee_resignation.Where(w => w.Emp_Resignation_Id != entity.Emp_Resignation_Id && w.Emp_Id == entity.Emp_Id && w.NoticePeriod == entity.NoticePeriod).Count(); } else //Insert Validation { intCount = adbContext.employee_resignation.Where(w => w.Emp_Id == entity.Emp_Id && w.NoticePeriod == entity.NoticePeriod).Count(); } return(intCount > 0 ? true : false); } catch (Exception ex) { throw ex; } }