public int SaveEmployee(MdlSaveEmp objEmp) { string strQuery = ""; if (objEmp.Id == 0) { strQuery = @"Insert into Employee(FName, LName, Designation, Email, Gender) values(@FName,@LName,@Designation,@Email,@Gender)"; } else if (objEmp.Id > 0) { strQuery = @"update Employee set FName = @FName, LName = @LName, Designation = @Designation, Email = @Email, Gender = @Gender where Id = @Id"; } return(_dbConnection.Execute(strQuery, objEmp)); }
public async Task <IActionResult> SaveEmployee(MdlSaveEmp objEmp) { _logger.LogInformation("In Save Employee."); //bool bHasEmail = _iEmpRepo.IsEmailIdExists(objEmp.Email, objEmp.Id); //if(bHasEmail) // return this.StatusCode(StatusCodes.Status409Conflict, "EmailId already exists."); int result = await Task.Run(() => _iEmpRepo.SaveEmployee(objEmp)); if (result == 1) { return(this.StatusCode(StatusCodes.Status201Created, "Successfully Saved")); } else { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Internal Server Error.")); } }