public HttpResponseMessage CreateCustomer(CustomerInsertDTO customer) { HttpResponseMessage message; try { // CustomerDataAccessLayer dal = new CustomerDataAccessLayer(); var dynObj = new { result = _Customer.InsertCustomer(customer) }; message = Request.CreateResponse(HttpStatusCode.OK, dynObj); } catch (Exception ex) { message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Something wrong. Try Again!" }); ErrorLog.CreateErrorMessage(ex, "Customer", "CreateCustomer"); } return(message); }
public bool InsertCustomer(CustomerInsertDTO objCustomer) { bool res = false; SqlCommand SqlCmd = new SqlCommand("spInsertCustomer"); SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.AddWithValue("@Name", objCustomer.Name); SqlCmd.Parameters.AddWithValue("@ClientId", objCustomer.ClientId); SqlCmd.Parameters.AddWithValue("@ContactNo", objCustomer.ContactNo); SqlCmd.Parameters.AddWithValue("@Mobile", objCustomer.Mobile); SqlCmd.Parameters.AddWithValue("@Email", objCustomer.Email); SqlCmd.Parameters.AddWithValue("@Address", objCustomer.Address); SqlCmd.Parameters.AddWithValue("@State", objCustomer.State); SqlCmd.Parameters.AddWithValue("@City", objCustomer.City); SqlCmd.Parameters.AddWithValue("@IGST", objCustomer.IGST); SqlCmd.Parameters.AddWithValue("@CGST", objCustomer.CGST); SqlCmd.Parameters.AddWithValue("@GSTNumber", objCustomer.GSTNo); SqlCmd.Parameters.AddWithValue("@PANNumber", objCustomer.PANNumber); SqlCmd.Parameters.AddWithValue("@SGST", objCustomer.SGST); SqlCmd.Parameters.AddWithValue("@CompanyId", objCustomer.CompanyId); SqlCmd.Parameters.AddWithValue("@CINNumber", objCustomer.CINNumber); SqlCmd.Parameters.AddWithValue("@ConcernPerson", objCustomer.ConcernPerson); SqlCmd.Parameters.AddWithValue("@ContactPerson", objCustomer.ContactPerson); SqlCmd.Parameters.AddWithValue("@CreatedBy", objCustomer.CreatedBy); int result = _unitOfWork.DbLayer.ExecuteNonQuery(SqlCmd); if (result != Int32.MaxValue) { res = true; } else { res = false; } return(res); }