public HttpResponseMessage TransactionDetails(HttpRequestMessage req, DL_Transaction trans) { User user = new User() { Password = trans.Key, UserId = trans.UserId }; Validation.UserCheck(user); if (Validation._IsSuccess) { try { // Logger.WriteLog(LogLevelL4N.INFO, "Params | UserId : " + trans.UserId + "UserType :" + trans.Pass + " FromDate : " + trans.FromDate + " ToDate :" + trans.ToDate); if (trans != null && !string.IsNullOrEmpty(trans.UserId) && !string.IsNullOrEmpty(trans.Key)) { if (string.IsNullOrEmpty(trans.FromDate) && string.IsNullOrEmpty(trans.ToDate)) { trans.ToDate = null; trans.FromDate = null; } //if (trans.StatusId < 0) //trans.StatusId = 0; //if (trans.TypeId < 0) //trans.StatusId = 0; DL_TransactionReturn transReturn = dash.TransactionSummary(trans); if (dash._IsSuccess) { return(req.CreateResponse <DL_TransactionReturn>(HttpStatusCode.OK, transReturn)); } else { return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, "ServerError")); } } Logger.WriteLog(LogLevelL4N.FATAL, "Bad Request"); return(req.CreateResponse(HttpStatusCode.BadRequest, "Bad Request")); } catch (Exception ex) { Logger.WriteLog(LogLevelL4N.ERROR, "Inside the transactionDetails api | Error : " + ex.Message); } } Logger.WriteLog(LogLevelL4N.FATAL, "Unauthorized Request"); return(req.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized")); }
//Transaction Details public DL_TransactionReturn TransactionSummary(DL_Transaction trans) { transReturn = new DL_TransactionReturn(); this.SpName = DL_StoreProcedure.SP_DHS_API_GetTransactionDetails; //Sp Name _IsSuccess = true; try { SqlParameter[] param = new SqlParameter[5]; param[0] = new SqlParameter("@UserId", trans.UserId); param[1] = new SqlParameter("@FromDate", trans.FromDate); param[2] = new SqlParameter("@ToDate", trans.ToDate); param[3] = new SqlParameter("@StatusId", trans.StatusId); param[4] = new SqlParameter("@TypeId", trans.TypeId); ds = db.GetDataSet(this.SpName, param); if (ds != null && ds.Tables.Count > 0) { //ds.Tables var Json = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None); List <DL_TransactionReturns> transReturns = JsonConvert.DeserializeObject <List <DL_TransactionReturns> >(Json); double totalAmount = 0, totalProfit = 0; foreach (var item in transReturns) { if (item.OpType == 2 || item.OpType == 3 || item.OpType == 8 || item.OpType == 1100 || item.OpType != 1400)//show profit only for no-fixed charged services { totalProfit += Convert.ToDouble(item.Profit); } if (item.OpType != 1400 && item.Status == "Success")//refund type { totalAmount += Convert.ToDouble(item.Amount); } } transReturn.dL_TransactionReturns = transReturns; transReturn.TotalAmount = totalAmount; transReturn.TotalProfit = Math.Round(totalProfit, 2); } } catch (Exception ex) { Logger.WriteLog(LogLevelL4N.ERROR, "Exception : " + ex.Message); _IsSuccess = false; } return(transReturn); }