//Profit Summary
        public DL_ProfitSummaryReturn ProfitSummary(DL_ProfitSummary profitSummary)
        {
            this.SpName  = DL_StoreProcedure.SP_DHS_API_Profit; //Sp Name
            profitReturn = new DL_ProfitSummaryReturn();
            _IsSuccess   = true;
            try
            {
                SqlParameter[] param = new SqlParameter[3];
                param[0] = new SqlParameter("@UserId", profitSummary.UserId);
                param[1] = new SqlParameter("@FromDate", profitSummary.FromDate);
                param[2] = new SqlParameter("@ToDate", profitSummary.ToDate);
                ds       = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    //ds.Tables[0].TableName = "Transaction";
                    //ds.Tables[1].TableName = "Retailer";
                    //ds.Tables
                    var    Json        = JsonConvert.SerializeObject(ds.Tables[0]);
                    var    profits     = JsonConvert.DeserializeObject <List <DL_ProfitSummarys> >(Json);
                    Double totalProfit = 0;
                    double totalAmount = 0;
                    foreach (var item in profits)
                    {
                        totalAmount += Convert.ToDouble(item.Amount);
                        totalProfit += Convert.ToDouble(item.UserProfit);
                    }
                    profitReturn = new DL_ProfitSummaryReturn()
                    {
                        dL_ProfitSummarys = profits, TotalAmount = totalAmount, TotalProfit = totalProfit
                    };
                }
            }
            catch (Exception ex)
            {
                _IsSuccess = false;
                Logger.WriteLog(LogLevelL4N.ERROR, "DL_ProfitSummaryReturn | Exception : " + ex.Message);
            }

            return(profitReturn);
        }
        public HttpResponseMessage ProfitSummary(HttpRequestMessage req, DL_ProfitSummary profit)
        {
            Logger.WriteLog(LogLevelL4N.ERROR, "Got ProfitSummary req.");
            User user = new User()
            {
                Password = profit.Key, UserId = profit.UserId
            };

            Validation.UserCheck(user);
            if (Validation._IsSuccess)
            {
                try
                {
                    if (profit != null && !string.IsNullOrEmpty(profit.UserId) && !string.IsNullOrEmpty(profit.Key))
                    {
                        //Logger.WriteLog(LogLevelL4N.INFO, "Process request |  UserId : " + profit.UserId + " UserType : " + profit.Key);
                        DL_ProfitSummaryReturn profitSumReturn = dash.ProfitSummary(profit);
                        if (dash._IsSuccess)
                        {
                            return(req.CreateResponse <DL_ProfitSummaryReturn>(HttpStatusCode.OK, profitSumReturn));
                        }
                        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 ProfitSummary api | Error : " + ex.Message);
                }
            }
            Logger.WriteLog(LogLevelL4N.FATAL, "Unauthorized Request");
            return(req.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized"));
        }