public async Task <IHttpActionResult> GetDepositInvoice(long id) { DepositInvoice depositInvoice = await db.DepositInvoices.FindAsync(id); if (depositInvoice == null) { return(NotFound()); } return(Ok(depositInvoice)); }
public async Task <IHttpActionResult> PostDepositInvoice(DepositInvoice depositInvoice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (DepositInvoiceExists(depositInvoice.Id)) { db.Entry(depositInvoice).State = EntityState.Modified; } else { db.DepositInvoices.Add(depositInvoice); } // add code to create signature if needed (Pasargad): //Move these to a method to free space here // var sign = RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); /* rsa.FromXmlString(“< RSAKeyValue >< Modulus > oQRshGhLf2Fh...”); * کلید خصوصی فروشنده// * string data = "#" + merchantCode + "#" + terminalCode + "#" + invoiceNumber + "#" + invoiceDate + "#" + amount + "#" + redirectAddress + "#" + action + "#" + timeStamp + "#"; + byte[] signMain = rsa.SignData(Encoding.UTF8.GetBytes(data), new + SHA1CryptoServiceProvider()); + sign = Convert.ToBase64String(signMain);*/ await db.SaveChangesAsync(); var sign = ""; return(CreatedAtRoute("DefaultApi", new { id = depositInvoice.Id }, new { Id = depositInvoice.Id, Sign = sign })); }