public dynamic GetInvoiceDetail(MvInvoice invoice) { var jsonNew = JsonConvert.SerializeObject(invoice); using (var conn = _dah.GetConnection()) { using (var cmd = new SqlCommand("SpInvoiceDetailSel", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Json", SqlDbType.NChar).Value = jsonNew; cmd.CommandTimeout = int.Parse(_commandTimeout); using (var reader = cmd.ExecuteReader()) { try { if (reader.HasRows) { return(_dah.GetJson(reader)); } return(null); } catch (Exception ex) { throw ex; } } } } }
public dynamic CreateInvoice(MvInvoice invoice) { using (var dbConnection = _dah.GetConnection()) { var dbCommand = dbConnection.CreateCommand(); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "SpInvoiceIns"; dbCommand.Parameters.Add("@Json", SqlDbType.NVarChar); dbCommand.Parameters["@Json"].Value = "{\"customerId\":" + invoice.CustomerId + "," + "\"sales\": " + invoice.Sales + "," + "\"insertPersonId\": 1337 }"; using (SqlDataReader reader = dbCommand.ExecuteReader()) { try { if (reader.HasRows) { return(_dah.GetJson(reader)); } else { return(null); } } catch (Exception e) { throw e; } } } }
public dynamic AddInvoice(MvInvoice invoice) { using (var dbConnection = _dah.GetConnection()) { var dbCommand = dbConnection.CreateCommand(); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "SpInvoiceInsertTsk"; dbCommand.Parameters.Add("@Json", SqlDbType.NVarChar); dbCommand.Parameters["@Json"].Value = "{\"entityType\":" + invoice.EntityType + "," + "\"entityId\":" + invoice.EntityId + "," + "\"transaction\":" + invoice.Transactions + "," + "\"insertPersonId\":" + invoice.InsertPersonId + "}"; using (SqlDataReader reader = dbCommand.ExecuteReader()) { try { if (reader.HasRows) { return(_dah.GetJson(reader)); } else { return(null); } } catch (Exception e) { throw e; } } } }
public IActionResult AddInvoice([FromBody] MvInvoice invoice) { try { dynamic jsonString = _invoiceService.CreateInvoice(invoice); return(Ok(jsonString)); } catch (Exception e) { throw e; } }
public IActionResult GenerateSingleInvoice(MvInvoice invoice) { if (!ModelState.IsValid) { return(BadRequest()); } try { var data = _invoiceService.GetSingleInvoiceDetails(invoice); return(Ok(data)); } catch (Exception) { throw; } }
public IActionResult AddInvoice([FromBody] MvInvoice invoice) { try { var added = _invoiceService.AddInvoice(invoice); if (!added) { return(BadRequest()); } return(Ok()); } catch (Exception e) { throw e; } }
public IActionResult GetInvoiceDetail(MvInvoice invoice) { if (!ModelState.IsValid) { return(BadRequest()); } try { var jsonString = _invoiceService.GetInvoiceDetail(invoice); return(Ok(jsonString)); } catch (Exception) { throw; } }
public bool AddInvoice(MvInvoice invoice) { using (var connection = _dah.GetConnection()) { var jsonNew = JsonConvert.SerializeObject(invoice); var command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "SpInvoiceIns"; command.Parameters.Add("@json", SqlDbType.NChar).Value = jsonNew; command.CommandTimeout = _comdTimeout; int rows = command.ExecuteNonQuery(); if (rows > 0) { return(true); } return(false); } }
public dynamic GetSingleInvoiceDetails(MvInvoice invoice) { var jsonConvert = JsonConvert.SerializeObject(invoice); using (var sql = _dah.GetConnection()) { using (SqlCommand command = new SqlCommand("SpInvoiceSelOneUser", sql)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@json", jsonConvert)); using (var reader = command.ExecuteReader()) { if (reader.HasRows) { Console.WriteLine("invoice Detail"); return(_dah.GetJson(reader)); } return(null); } } } }