/// <summary> /// database connection for Add new entry /// </summary> /// <param name="data">Add new Entry</param> /// <returns></returns> public async Task <bool> AddEmployeeData(Addentry data) { try { SqlConnection connection = DatabaseConnection(); //for store procedure and connection to database SqlCommand command = StoreProcedureConnection("spAdddnewEmployees", connection); command.Parameters.AddWithValue("@EmployeeName", data.EmployeeName); command.Parameters.AddWithValue("@Username", data.Username); command.Parameters.AddWithValue("@Gender", data.Gender); command.Parameters.AddWithValue("@City", data.City); command.Parameters.AddWithValue("@EmailID", data.EmailID); command.Parameters.AddWithValue("@Designation", data.Designation); command.Parameters.AddWithValue("@WorkingExperience", data.WorkingExperience); connection.Open(); int Response = await command.ExecuteNonQueryAsync(); connection.Close(); if (Response != 0) { return(true); } else { return(false); } } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <IActionResult> AddEmployeeData([FromBody] Addentry Info) { try { bool result = await BusinessLayer.AddEmployeeData(Info); //if entry is not equal to null then Login sucessful if (!result.Equals(null)) { var status = "Success"; var Message = "New Entry Added Sucessfully"; return(this.Ok(new { status, Message, data = Info })); } else //Entry is not added { var status = "Unsuccess"; var Message = "New Entry is not Added"; return(this.BadRequest(new { status, Message, data = Info })); } } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// API for Add new entry /// </summary> /// <param name="data">Add new Entry</param> /// <returns></returns> public async Task <bool> AddEmployeeData(Addentry data) { try { var Result = await _EmployeeRepository.AddEmployeeData(data); //if result is not equal null then return true if (!Result.Equals(null)) { return(true); } else { return(false); } } catch (Exception e) { throw new Exception(e.Message); } }