public object ReverseTaxLotAlleviation(TaxLotReversalDto obj) { try { foreach (var item in obj.ClosingLots) { var taxLotStatus = obj.OpenLots.Where(x => x.OpenLotId == item.OpenLotId).FirstOrDefault(); int remainingAfterReversal = Math.Abs(item.Quantity) + Math.Abs(taxLotStatus.RemainingQuantity); if (taxLotStatus.Side == "SHORT") { taxLotStatus.RemainingQuantity = remainingAfterReversal * -1; } else { taxLotStatus.RemainingQuantity = remainingAfterReversal; } if (taxLotStatus.OriginalQuantity == taxLotStatus.RemainingQuantity) { taxLotStatus.Status = "Open"; } else { taxLotStatus.Status = "Partially Closed"; } } SqlHelper sqlHelper = new SqlHelper(connectionString); sqlHelper.VerifyConnection(); sqlHelper.SqlBeginTransaction(); UpdateTaxLot(obj, sqlHelper); UpdateTaxLotStatus(obj.OpenLots, sqlHelper); sqlHelper.SqlCommitTransaction(); sqlHelper.CloseConnection(); return(Utils.Wrap(true, null, HttpStatusCode.OK)); } catch (Exception ex) { throw ex; } }
private static void UpdateTaxLot(TaxLotReversalDto obj, SqlHelper sqlHelper) { var listOfClosingLotParameters = new List <List <SqlParameter> >(); foreach (var item in obj.ClosingLots) { List <SqlParameter> closingLotParams = new List <SqlParameter> { new SqlParameter("id", item.Id) }; listOfClosingLotParameters.Add(closingLotParams); } var taxLotQuery = $@"UPDATE [dbo].[tax_lot] SET [active_flag] = 0 where [id] = @id"; foreach (var item in listOfClosingLotParameters) { sqlHelper.Update(taxLotQuery, CommandType.Text, item.ToArray()); } }
public object ReverseTaxLot(TaxLotReversalDto obj) { return(controller.ReverseTaxLotAlleviation(obj)); }
public object ReverseTaxLotAlleviation(TaxLotReversalDto obj) { throw new NotImplementedException(); }