public async Task <ActionResult> Get(DailyRevenueConfirmFCViewModel Filter)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            string filetype = HttpContext.Request.Query["FileType"].ToString().ToLower();

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            StringBuilder sqlStringBuilder = new StringBuilder();

            sqlStringBuilder.Append("EXEC sp_PDC_Report_DailyRevenueConfirmFC_Get '");
            sqlStringBuilder.Append(Filter.ConfirmBy);
            sqlStringBuilder.Append("','");
            sqlStringBuilder.Append(UserData.Username);
            sqlStringBuilder.Append("','");
            sqlStringBuilder.Append(Filter.BranchList);
            sqlStringBuilder.Append("','");
            sqlStringBuilder.Append(dateFrom.ToString("yyyyMMdd", enUS));
            sqlStringBuilder.Append("','");
            sqlStringBuilder.Append(dateTo.ToString("yyyyMMdd", enUS));
            sqlStringBuilder.Append("'");

            string strSQL = sqlStringBuilder.ToString();

            List <DailyRevenueConfirmFC> DailyRevenues = await DB.DailyRevenueConfirmFC.FromSql(strSQL).ToListAsync();

            if (filetype.Equals("excel"))
            {
                return(ExportExcelDailyRevenueConfirmFC(DailyRevenues));
            }

            int totalCount = DailyRevenues.Count();

            DailyRevenues = DailyRevenues.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = DailyRevenues;
            Response.ResultInfo = new
            {
                page    = pagination.Page,
                perPage = pagination.PerPage,
                count   = DailyRevenues.Count(),
                totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
        public async Task <ActionResult> Get(BranchMonthlyViewModel Filter)
        {
            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            string FileType = Request.Query["FileType"];
            string Type     = Request.Query["Type"];

            if (Type == null)
            {
                Type = "";
            }

            DateTime monthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS);

            StringBuilder SQLStringBuilder = new StringBuilder();

            SQLStringBuilder.Append("EXEC sp_RPT313_DHLVerifyReport '");
            SQLStringBuilder.Append(UserData.Username);
            SQLStringBuilder.Append("', '");
            SQLStringBuilder.Append(Filter.BranchList);
            SQLStringBuilder.Append("', '");
            SQLStringBuilder.Append(monthYear.Month.ToString());
            SQLStringBuilder.Append("', '");
            SQLStringBuilder.Append(monthYear.Year.ToString());
            SQLStringBuilder.Append("'");

            string sql = SQLStringBuilder.ToString();

            List <DHLVerify> DHLVerify = await DB.DHLVerify.FromSql(sql).ToListAsync();

            if (FileType != null)
            {
                if (FileType.Equals("excel"))
                {
                    //return ExportExcelLINEPayRemittance(Type, LINEPayRemittance);
                }
            }

            int totalCount = DHLVerify.Count;

            DHLVerify = DHLVerify.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = DHLVerify;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = DHLVerify.Count,
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Get(BranchMonthlyViewModel Filter, String FileType)
        {
            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            // Ref Page
            string type     = Request.Query["Type"];
            string VerifyID = "";

            switch (type)
            {
            case "acc":
                VerifyID = "EXPENSE_VERIFY_FOR_ACC";
                break;
            }

            DateTime monthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS);

            string exec = $"sp_RPT300_FN_MonthlyExpenseSync '{UserData.Username}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'";

            _logger.LogInformation(exec);
            await DB.Database.ExecuteSqlCommandAsync(exec);

            exec = $"EXEC sp_RPT310_GetMonthlyExpense '{UserData.Username}', '{Filter.BranchList}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}', '{VerifyID}'";
            _logger.LogInformation(exec);
            List <MonthlyExpense> MonthlyExpense = await DB.MonthlyExpense.FromSql(exec).ToListAsync();

            if (FileType != null)
            {
                if (FileType.Equals("excel"))
                {
                    return(ExportExcelMonthlyExpense(MonthlyExpense));
                }
            }

            int totalCount = MonthlyExpense.Count();

            MonthlyExpense = MonthlyExpense.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = MonthlyExpense;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = MonthlyExpense.Count(),
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Get(TypeBranchDateFromDateToViewModel Filter, string FileType)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            string filetype = (FileType ?? "").ToLower();

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            string      userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            string parameter = "'" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'";

            string sql = "EXEC sp_PDC_Report_DailyRevenueVerify_Get " + parameter;

            _logger.LogInformation(sql);

            IQueryable <DailyRevenueVerify> queryableDailyRevenueVerify = DB.DailyRevenueVerify.FromSql(sql);

            if (filetype.Equals("excel"))
            {
                //string exec = $"sp_PDC_Dashboard_EODCoverPage_Get '{dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '{UserData.Username}', '{filter.BranchList}'";
                string           exec         = $"sp_PDC_Dashboard_CloseShopCoverPage_Get '{dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{dateTo.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{UserData.Username}', '{Filter.BranchList}'";
                IQueryable <EOD> queryableEOD = DB.EOD.FromSql(exec);

                return(ExportExcelDailyRevenueVerify(dateFrom, dateTo, Filter.BranchList, await queryableDailyRevenueVerify.ToListAsync(), await queryableEOD.ToListAsync()));
            }

            int totalCount = queryableDailyRevenueVerify.Count();
            List <DailyRevenueVerify> DailyRevenueVerify = queryableDailyRevenueVerify.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = DailyRevenueVerify;
            Response.ResultInfo = new
            {
                page    = pagination.Page,
                perPage = pagination.PerPage,
                count   = DailyRevenueVerify.Count(),
                totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 5
0
        // GET Api/<controller>
        public async Task <ActionResult> Get(BranchMonthlyViewModel Filter, String FileType, String Type)
        {
            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            if (Type == null)
            {
                Type = "";
            }

            DateTime monthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS);

            string exec = $"sp_RPT300_FN_MonthlyExpenseSync '{UserData.Username}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'";

            _logger.LogInformation(exec);
            await DB.Database.ExecuteSqlCommandAsync(exec);

            exec = $"EXEC sp_PDC_Report_MonthlyCommissionSummary_Get '{UserData.Username}', '{Filter.BranchList}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}', { (Type.Equals("rt") ? "0" : "1") }, ''";
            _logger.LogInformation(exec);
            List <MonthlySummaryCommission> MonthlySummaryCommission = await DB.MonthlySummaryCommission.FromSql(exec).ToListAsync();

            if (FileType != null)
            {
                if (FileType.Equals("excel"))
                {
                    return(ExportExcelMonthlyCommission(Type, MonthlySummaryCommission, monthYear));
                }
            }

            int totalCount = MonthlySummaryCommission.Count();

            MonthlySummaryCommission = MonthlySummaryCommission.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = MonthlySummaryCommission;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = MonthlySummaryCommission.Count(),
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
        public async Task <Object> Post(BranchDateFromDateToViewModel Filter)
        {
            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            string FileType = Request.Form["filetype"];
            string Type     = Request.Form["Type"];

            if (Type == null)
            {
                Type = "";
            }

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            string sql = $"EXEC sp_PDC_Report_DCTopUpVerify_Get '{dateFrom.ToString("yyyyMMdd", enUS)}', '{dateTo.ToString("yyyyMMdd", enUS)}', '{UserData.Username}', '{Filter.BranchList}'";

            _logger.LogInformation(sql);
            List <LINEPayRemittance> LINEPayRemittance = await DB.LINEPayRemittance.FromSql(sql).ToListAsync();

            if (FileType != null)
            {
                if (FileType.Equals("excel"))
                {
                    return(ExportExcel(dateFrom, dateTo, LINEPayRemittance));
                }
            }

            int totalCount = LINEPayRemittance.Count;

            LINEPayRemittance = LINEPayRemittance.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = LINEPayRemittance;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = LINEPayRemittance.Count,
                totalCount = totalCount
            };

            DB.Dispose();

            return(Response.Render());
        }
        public async Task <object> Detail(string id, DateTime ReportDate)
        {
            try
            {
                var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
                UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);
                var         date     = ReportDate.ToString("yyyyMMdd", enUS);
                //DateTime dateStr = DateTime.ParseExact(ReportDate, "dd/MM/yyyy", enUS);
                string exec = $"EXEC sp_PDC_Report_DailyRevenueVerifyMatchCash_Get '{UserData.Username}', '{id}', '{ReportDate.ToString("yyyyMMdd", enUS)}'";
                //string exec1 = $"EXEC sp_PDC_Report_DailyRevenueVerifyMatchCash_Get  '{id}', '{ReportDate.ToString("yyyyMMdd", enUS)}'";
                _logger.LogInformation(exec);

                DailyRevenueDetailCash Detail = await DB.DailyRevenueDetailCash.FromSql(exec).FirstOrDefaultAsync();

                if (Detail == null)
                {
                    return(ResponseNotFound(id));
                }

                Response.Success = true;
                Response.Result  = Detail;
                DB.Dispose();

                return(Response.Render());
            }
            catch (Exception ex)
            {
                string mss = ex.Message.ToString();
                return(null);
            }
            // Auth Data
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Get(ShopDailyViewModel Filter)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            string type     = HttpContext.Request.Query["Type"].ToString().ToLower();
            string filetype = HttpContext.Request.Query["FileType"].ToString().ToLower();

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime date = DateTime.ParseExact(Filter.Date, "dd/MM/yyyy", new CultureInfo("en-US"));

            List <DashboardShopDaily> DashboardShopDaily = await DB.DashboardShopDaily
                                                           .FromSql($"EXEC sp_RPT316_ShopDaily '{UserData.Username}', '{Filter.BranchList}', '{date.ToString("yyyyMMdd", new CultureInfo("en-US"))}'")
                                                           .ToListAsync();

            Response.Success = true;
            Response.Result  = DashboardShopDaily;

            DB.Dispose();

            return(Json(Response.Render()));
        }
        private async Task <IActionResult> Report(int id, ViewResult viewResult, string with)
        {
            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            switch (with)
            {
            case "BranchList":
                ViewData["BranchList"] = await DB.BranchList.FromSql("EXEC sp_RPT309_GetUserShopListByProfileId '" + UserData.Username + "', '" + null + "', 0").ToListAsync();

                break;

            case "BranchListWithERP":
                ViewData["BranchList"] = await DB.BranchList.FromSql("EXEC sp_RPT309_GetUserShopListByProfileId '" + UserData.Username + "', '" + null + "', 1").ToListAsync();

                break;

            case "UserProfile":
                ViewData["UserProfile"] = await DB.UserProfile.ToListAsync();

                break;

            case "MonthlyExpenseUpdateRT":
                ViewData["UserProfile"] = await DB.UserProfile.ToListAsync();

                break;

            case "DC-SHOP":
                ViewData["BranchList"] = await DB.BranchList.FromSql("EXEC sp_RPT301_GetBranchList '" + UserData.Username + "', 'DC-SHOP'").ToListAsync();

                break;
            }

            List <Package> PackageAll = await DB.Package.OrderBy(p => p.UnitPrice).ToListAsync();

            ViewData["PackageAll"] = PackageAll;

            var searchPackage = new List <string> {
                "PKG03", "PKG04", "PKG05", /*"PKG06",*/ "PKG07", "PKG08", "PKG18"
            };

            ViewData["PackageList"] = PackageAll
                                      .Where(p => searchPackage.Contains(p.PackageID))
                                      .ToList();

            ViewData["SupplyList"] = PackageAll
                                     .Where(p => (new[] { 4, 5 }).Contains(p.PackageType.Value))
                                     .OrderBy(p => p.UnitPrice)
                                     .ToList();

            DB.Dispose();

            return(viewResult);
        }
        // GET: /<controller>/Type
        public async Task <object> Type()
        {
            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            string sql = $"EXEC sp_PDC_BranchType_Get_Auth'{ UserData.Username }'";

            Response.Success = true;
            Response.Result  = await DB.BranchType.FromSql(sql)
                               .GroupBy(t => t.TypeGroup, (key, list) => new
            {
                TypeGroupId = key,
                Types       = list
            })
                               .ToListAsync();

            DB.Dispose();

            return(Response.Render());
        }
        public async Task <ActionResult> Get(TypeBranchDateFromDateToViewModel Filter, string FileType)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            string filetype = (FileType ?? "").ToLower();

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            string parameter = "'" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'";

            string sql = "EXEC sp_PDC_Report_StockOrder_Get " + parameter;

            _logger.LogInformation(sql);

            List <StockOrder> StockOrder = await DB.StockOrder.FromSql(sql).ToListAsync();

            if (filetype.Equals("excel"))
            {
                return(ExportExcel(dateFrom, dateTo, StockOrder));
            }

            int totalCount = StockOrder.Count();

            StockOrder = StockOrder.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = StockOrder;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = StockOrder.Count(),
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 12
0
        public async Task <JsonResult> Post(UpdatePRViewModel UpdatePR)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime monthYear = DateTime.ParseExact(UpdatePR.MonthYear, "MM/yyyy", enUS);

            StringBuilder SQLStringBuilder = new StringBuilder();

            for (int i = 0; i < UpdatePR.BranchID.Count(); i++)
            {
                SQLStringBuilder.AppendLine($"EXEC sp_RPT312_UpdatePR '{UserData.Username}', '{UpdatePR.BranchID[i]}', '{UpdatePR.PR[i]}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'");
            }

            string strSQL = SQLStringBuilder.ToString();

            #region Product
            if (_hostingEnvironment.IsProduction())
            {
                SaveDBResponse save = await DB.SaveDBResponse.FromSql(strSQL).FirstAsync();

                Response.Success = save.code.Equals("000");
                Response.Messages.Add(save.desc);
            }
            #endregion

            #region Tester
            else
            {
                Response.Success = true;
                Response.Messages.Add("Test");
            }
            #endregion

            DB.Dispose();

            return(Json(Response.Render()));
        }
        // GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            // Parameter
            string profile_id = HttpContext.Request.Query["FC"].ToString().ToUpper();

            if (profile_id.Equals("ALL"))
            {
                profile_id = "";
            }

            Response.Success = true;
            Response.Result  = await DB.BranchList.FromSql("EXEC sp_RPT309_GetUserShopListByProfileId '" + UserData.Username + "', '" + profile_id + "'").ToListAsync();

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 14
0
        public async Task <ActionResult> DiscountReport(ReqDiscount ReqDiscount, string FileType)
        {
            try
            {
                string[] lines = ReqDiscount.BranchList.Split(",");

                Pagination pagination = new Pagination(HttpContext);


                string filetype = (FileType ?? "").ToLower();

                DateTime DateTo   = DateTime.ParseExact(ReqDiscount.DateTo, "dd/MM/yyyy", new CultureInfo("en-US"));
                DateTime DateFrom = DateTime.ParseExact(ReqDiscount.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US"));
                if (filetype.Equals("excel"))
                {
                    return(ExportExcelDiscountReport(ReqDiscount, DateTo, DateFrom));
                }
                List <BranchIdList> _items = new List <BranchIdList>();
                foreach (var branch in lines)
                {
                    BranchIdList _b = new BranchIdList
                    {
                        BranchId = branch.ToString()
                    };
                    _items.Add(_b);
                }
                List <DiscountTypeList> _Dis = new List <DiscountTypeList>();
                foreach (var DiscountType in ReqDiscount.DiscountTypeList)
                {
                    DiscountTypeList _d = new DiscountTypeList
                    {
                        DiscountType = DiscountType.ToString()
                    };
                    _Dis.Add(_d);
                }

                ReqDiscountType DiscountTypeList = new ReqDiscountType
                {
                    DateFrom         = DateFrom.ToString("yyyyMMdd"),
                    DateTo           = DateTo.ToString("yyyyMMdd"),
                    BranchIdList     = _items,
                    DiscountTypeList = _Dis
                };

                string       json      = JsonConvert.SerializeObject(DiscountTypeList);
                SqlParameter jsonInput = new SqlParameter()
                {
                    ParameterName = "@jsonreq",
                    SqlDbType     = SqlDbType.NVarChar,
                    SqlValue      = json,
                    Size          = int.MaxValue
                };

                SqlParameter jsonOutput = new SqlParameter()
                {
                    ParameterName = "@jsonOutput",
                    SqlDbType     = SqlDbType.NVarChar,
                    Direction     = ParameterDirection.Output,
                    Size          = int.MaxValue
                };



                DB.Database.ExecuteSqlCommand(" sp_PDC_Discount_Report_Detail @jsonreq, @jsonOutput OUTPUT ", jsonInput, jsonOutput);
                var data = jsonOutput.Value.ToString();
                if (data == "" || data == null)
                {
                    Response.Success    = false;
                    Response.Result     = DiscountTypeList;
                    Response.ResultInfo = new
                    {
                        page       = pagination.Page,
                        perPage    = pagination.PerPage,
                        count      = 0,
                        totalCount = 0
                    };
                    return(Json(Response.Render()));
                }
                //JObject dd = JObject.Parse("[" + jsonOutput.Value.ToString() + "]");
                ResResultDiscount Discount = JsonConvert.DeserializeObject <ResResultDiscount>(jsonOutput.Value.ToString());

                //GlobalVal._listDiscount = Discount;

                List <DiscountModel> disc = new List <DiscountModel>();
                foreach (var item in Discount.Result)
                {
                    DiscountModel dc = new DiscountModel
                    {
                        BranchType     = item.BranchType,
                        ERPID          = item.ERPID,
                        BranchId       = item.BranchId,
                        ReceiptNo      = item.ReceiptNo,
                        ReceiptDate    = item.ReceiptDate,
                        MemberId       = item.MemberId,
                        SenderName     = item.SenderName,
                        SenderMobile   = item.SenderMobile,
                        DiscountCode   = item.DiscountCode,
                        DiscountType   = item.DiscountType,
                        Surcharge      = item.Surcharge,
                        DiscountAmount = item.DiscountAmount
                    };
                    disc.Add(dc);
                }

                GlobalVal._listDiscount = disc;

                int totalCount = Discount.Result.Count();

                var _discount = Discount.Result.Skip(pagination.From()).Take(pagination.To()).ToList();

                Response.Success    = true;
                Response.Result     = disc;
                Response.ResultInfo = new
                {
                    page       = pagination.Page,
                    perPage    = pagination.PerPage,
                    count      = _discount.Count(),
                    totalCount = totalCount
                };

                DB.Dispose();

                return(Json(Response.Render()));
            }
            catch (Exception ex)
            {
                var mss = ex.Message.ToString();
                return(null);
            }
        }
Exemplo n.º 15
0
        public async Task <ActionResult> Get(ReportViewModel Filter, string type, string fileType)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            type     = (type ?? "").ToLower();
            fileType = (fileType ?? "").ToLower();

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            int    count      = 0;
            int    totalCount = 0;
            object result     = new List <object>();

            StringBuilder SQLStringBuilder = new StringBuilder();

            SQLStringBuilder.Append("EXEC sp_PDC_Report_Insurance '");
            SQLStringBuilder.Append(dateFrom.ToString("yyyyMMdd", enUS));
            SQLStringBuilder.Append("', '");
            SQLStringBuilder.Append(dateTo.ToString("yyyyMMdd", enUS));
            SQLStringBuilder.Append("', '");
            SQLStringBuilder.Append(UserData.Username);
            SQLStringBuilder.Append("', '");
            SQLStringBuilder.Append(Filter.BranchList);
            SQLStringBuilder.Append("'");

            String sqlStr = SQLStringBuilder.ToString();

            List <Insurance> Insurances = await DB.Insurance.FromSql(sqlStr).ToListAsync();

            if (fileType.Equals("excel"))
            {
                return(ExportExcelInsurance(Insurances, dateFrom, dateTo));
            }

            totalCount = Insurances.Count();

            Insurances = Insurances.Skip(pagination.From()).Take(pagination.To()).ToList();

            result = Insurances;
            count  = Insurances.Count();

            Response.Success    = true;
            Response.Result     = result;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = count,
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 16
0
        public object BillPayment(BranchesBillDateRangeViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Response.RenderError(ModelState));
                }
                List <BranchIdList> _items = new List <BranchIdList>();
                foreach (var branch in model.BranchIdList)
                {
                    BranchIdList _b = new BranchIdList
                    {
                        BranchId = branch
                    };
                    _items.Add(_b);
                }
                ReqReconcile _line = new ReqReconcile
                {
                    DateFrom = DateTime.ParseExact(model.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")).ToString("yyyyMMdd"),
                    DateTo   = DateTime.ParseExact(model.DateTo, "dd/MM/yyyy", new CultureInfo("en-US")).ToString("yyyyMMdd"),
                    //DateTo = DateTime.Parse(model.DateTo, new CultureInfo("en-US")).ToString("yyyyMMdd"),
                    BranchIdList = _items
                };

                string       json      = JsonConvert.SerializeObject(_line);
                SqlParameter jsonInput = new SqlParameter()
                {
                    ParameterName = "@jsonreq",
                    SqlDbType     = SqlDbType.NVarChar,
                    SqlValue      = json,
                    Size          = int.MaxValue
                };

                SqlParameter jsonOutput = new SqlParameter()
                {
                    ParameterName = "@jsonOutput",
                    SqlDbType     = SqlDbType.NVarChar,
                    Direction     = ParameterDirection.Output,
                    Size          = int.MaxValue
                };

                List <DailyRevenueReconcileBillPayment> dailyRevenueReconcile = DB.DailyRevenueReconcileBillPayment
                                                                                .FromSql(
                    "EXEC sp_PDC_Report_DailyRevenueReconcileBillPayment_Get {0}, {1}, {2}, {3}, {4}"
                    ).ToList();
                DB.Database.ExecuteSqlCommand(" sp_PDC_Reconcile_Report_DailyRevenue_Bill_Payment_Verify_Summary @jsonreq, @jsonOutput OUTPUT ", jsonInput, jsonOutput);
                //JObject dd = JObject.Parse("[" + jsonOutput.Value.ToString() + "]");
                List <SumMatching> RevenueData = JsonConvert.DeserializeObject <List <SumMatching> >("[" + jsonOutput.Value.ToString() + "]");
                //0 Unmatch, 1 Match, 2 Not found data


                Response.Success = true;
                Response.Result  = RevenueData;

                //Response.ResultInfo = new
                //{
                //    page = model.Page,
                //    perPage = model.PerPage,
                //    count = _line
                //};

                DB.Dispose();

                return(Response.Render());
            }
            catch (Exception ex)
            {
                return(Response.RenderError(ModelState));
            }
        }
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Dashboard"));
            }

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Login", "Users"));
            }

            try
            {
                if (model.option == "ssgn")
                {
                    //var ad = _api.LoginAD(model.Username, model.Password);
                    //SSOService EDI = new SSOService();
                    //EDI = JsonConvert.DeserializeObject<SSOService>(ad);

                    //if (EDI.ResultCode == "406" || EDI.ResultCode == "405")
                    //{
                    //    string LandingPage = EDI.LandingPage.ToString();


                    //    //return RedirectToAction("Login", "Users");
                    //    return RedirectToAction("Login", new RouteValueDictionary(
                    //      new { controller = "Users", action = "Login", LandingPage = LandingPage, status = EDI.ResultCode }));
                    //    //return Redirect(EDI.LandingPage.ToString());
                    //}
                    //if (EDI.ResultCode != "200")
                    //{
                    //    ModelState.AddModelError("failed", "Plase login by Single Sign On Only.");
                    //    return RedirectToAction("Login", "Users");
                    //}

                    UserMapRole user = new UserMapRole();

                    UserRole users = await DB.UserRole.FromSql("EXEC sp_PDC_Login_Get '" + model.Username + "'").Where(u => u.status != false).FirstAsync();

                    List <UserMenuRole> UserMenu = await DB.UserMenuRole.FromSql("EXEC sp_PDC_Get_Menu '" + model.Username + "'").ToListAsync();

                    user.UserMenu  = UserMenu;
                    user.Username  = users.user_id;
                    user.Name      = users.user_name;
                    user.RoleId    = users.user_role;
                    user.email     = users.user_role;
                    user.LastLogin = users.last_login;

                    //User user = await DB.User
                    //    .Include(u => u.UserGroup)
                    //    .Include(u => u.UserMenu)
                    //    .Include(u => u.UserProfile)
                    //    .Where(u => u.email.Equals(EDI.Email.ToLower()))
                    //    .FirstAsync();
                    var AuthUser = DB.AuthUser.SingleOrDefault(c => c.user_id == model.Username);

                    AuthUser.last_login = DateTime.Now;
                    DB.SaveChanges();


                    _logger.LogInformation($"Logged in {model.Username}.");

                    List <Claim> claims = new List <Claim> {
                        new Claim(ClaimTypes.NameIdentifier, user.Username, ClaimValueTypes.String),
                        new Claim(ClaimTypes.Name, user.Name, ClaimValueTypes.String),
                        new Claim(ClaimTypes.Role, user.RoleId.ToString(), ClaimValueTypes.String),
                        new Claim("User", JsonConvert.SerializeObject(user), new User().GetType().ToString()),
                    };

                    List <Menu> menus;

                    Stream fs = System.IO.File.OpenRead($@"{_hostingEnvironment.ContentRootPath}\menus.json");
                    using (StreamReader reader = new StreamReader(fs))
                    {
                        menus = JsonConvert.DeserializeObject <List <Menu> >(await reader.ReadToEndAsync());
                    }
                    fs.Dispose();

                    AddRole(user, menus, claims);

                    ClaimsIdentity  userIdentity  = new ClaimsIdentity(claims, "ApplicationCookie");
                    ClaimsPrincipal userPrincipal = new ClaimsPrincipal(userIdentity);

                    await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, userPrincipal);

                    //await DB.SaveChangesAsync();

                    DB.Dispose();
                }
                else
                {
                    UserMapRole user  = new UserMapRole();
                    UserRole    users = await DB.UserRole.FromSql("EXEC sp_PDC_Login_Get '" + model.Username + "'").Where(u => u.status != false).FirstAsync();

                    List <UserMenuRole> UserMenu = await DB.UserMenuRole.FromSql("EXEC sp_PDC_Get_Menu '" + model.Username + "'").ToListAsync();

                    user.UserMenu  = UserMenu;
                    user.Username  = users.user_id;
                    user.Name      = users.user_name;
                    user.RoleId    = users.user_role;
                    user.email     = users.user_role;
                    user.LastLogin = users.last_login;

                    bool is_auth = DB.AuthUser.Any(c => c.email == user.email);
                    if (is_auth)
                    {
                        ModelState.AddModelError("failed", "Plase login by Single Sign On Only.");
                        return(RedirectToAction("Login", "Users"));
                    }

                    user.LastLogin = DateTime.Now;
                    DB.SaveChanges();

                    //var users = DB.User.FromSql("SELECT userid AS Username, username AS name, role_id AS RoleId, profile_id AS ProfileId FROM tb_master_user AS u WITH(NOLOCK) WHERE userid = '" + model.Username + "' AND pwd = '" + model.Password + "'");

                    _logger.LogInformation($"Logged in {model.Username}.");


                    user.Password = string.Empty;

                    List <Claim> claims = new List <Claim> {
                        new Claim(ClaimTypes.NameIdentifier, user.Username, ClaimValueTypes.String),
                        new Claim(ClaimTypes.Name, user.Name, ClaimValueTypes.String),
                        new Claim(ClaimTypes.Role, user.RoleId.ToString(), ClaimValueTypes.String),
                        new Claim("User", JsonConvert.SerializeObject(user), new User().GetType().ToString()),
                    };

                    List <Menu> menus;

                    Stream fs = System.IO.File.OpenRead($@"{_hostingEnvironment.ContentRootPath}\menus.json");
                    using (StreamReader reader = new StreamReader(fs))
                    {
                        menus = JsonConvert.DeserializeObject <List <Menu> >(await reader.ReadToEndAsync());
                    }
                    fs.Dispose();

                    AddRole(user, menus, claims);

                    ClaimsIdentity  userIdentity  = new ClaimsIdentity(claims, "ApplicationCookie");
                    ClaimsPrincipal userPrincipal = new ClaimsPrincipal(userIdentity);

                    await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, userPrincipal);

                    //await DB.SaveChangesAsync();
                    var email = user.email;
                    if (email == null || email == "")
                    {
                        TempData["email"]    = "email";
                        TempData["username"] = user.Username;
                    }
                    else
                    {
                        TempData["email"] = user.email;
                    }

                    DB.Dispose();
                }


                return(RedirectToLocal(returnUrl));
            }
            catch (Exception e)
            {
                _logger.LogWarning($"Failed to login {model.Username}.");
                _logger.LogCritical(e.Message);
                ModelState.AddModelError("failed", "Invalid login attempt.");
                return(RedirectToAction("Login", "Users"));
            }
        }
        public async Task <ActionResult> Get(ReportViewModel Filter, string type, string fileType)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            type     = (type ?? "").ToLower();
            fileType = (fileType ?? "").ToLower();

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            string parameter  = "'" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'";
            int    count      = 0;
            int    totalCount = 0;
            object result     = new List <object>();

            #region ShopDailyRevenue
            if (type.Equals("shopdailyrevenue"))
            {
                List <ShopDailyRevenue> DailyRevenues = await DB.ShopDailyRevenue.FromSql("EXEC sp_RPT304_ShopDailyRevenue " + parameter + ", " + Filter.OrderBy.ToString()).ToListAsync();

                if (fileType.Equals("excel"))
                {
                    return(ExportExcelShopDailyRevenue(dateFrom, dateTo, DailyRevenues));
                }

                totalCount = DailyRevenues.Count();

                DailyRevenues = DailyRevenues.Skip(pagination.From()).Take(pagination.To()).ToList();

                result = DailyRevenues;
                count  = DailyRevenues.Count();
            }
            #endregion

            #region Receipt
            else if (type.Equals("receipt"))
            {
                List <Receipt> Receipts = await DB.Receipt.FromSql("EXEC sp_RPT305_ReceiptReport " + parameter).ToListAsync();

                if (fileType.Equals("excel"))
                {
                    return(ExportExcelReceipt(Receipts, dateFrom, dateTo));
                }

                totalCount = Receipts.Count();

                Receipts = Receipts.Skip(pagination.From()).Take(pagination.To()).ToList();

                result = Receipts;
                count  = Receipts.Count();
            }
            #endregion

            #region TaxInvoice
            else if (type.Equals("taxinvoice"))
            {
                List <TaxInvoice> TaxInvoices = await DB.TaxInvoice.FromSql("EXEC sp_RPT306_TaxInvoiceReport " + parameter + ", " + (Filter.Canceled == null || Filter.Canceled.Equals(false) ? "0" : "1")).ToListAsync();

                if (fileType.Equals("excel"))
                {
                    return(ExportExcelTaxInvoice(TaxInvoices, dateFrom, dateTo));
                }

                totalCount = TaxInvoices.Count();

                TaxInvoices = TaxInvoices.Skip(pagination.From()).Take(pagination.To()).ToList();

                result = TaxInvoices;
                count  = TaxInvoices.Count();
            }
            #endregion

            #region MonthlyCommission
            else if (type.Equals("commission"))
            {
                DateTime MonthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS);
                List <MonthlyCommission> MonthlyCommissions = await DB.MonthlyCommission.FromSql("EXEC sp_RPT307_MonthlyCommission '" + MonthYear.ToString("yyyyMM", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'").ToListAsync();

                if (fileType.Equals("excel"))
                {
                    dateFrom = MonthYear;
                    dateTo   = MonthYear.AddMonths(1).AddDays(-1);
                    List <DailyCommission> DailyCommissions = await DB.DailyCommission.FromSql("EXEC sp_RPT307_DailyCommission '" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'").ToListAsync();

                    return(ExportExcelMonthlyCommissions(DailyCommissions, MonthlyCommissions));
                }

                totalCount = MonthlyCommissions.Count();

                MonthlyCommissions = MonthlyCommissions.Skip(pagination.From()).Take(pagination.To()).ToList();

                result = MonthlyCommissions;
                count  = MonthlyCommissions.Count();
            }
            #endregion

            #region LINEPay
            else if (type.Equals("linepay"))
            {
                string LineType = HttpContext.Request.Query["TypeLine"].ToString().ToLower();

                List <LINEPay> LINEPay     = new List <Models.LINEPay> {
                };
                List <LINETopUp> LINETopUp = new List <Models.LINETopUp> {
                };

                if (LineType.Equals("payment") || fileType.Equals("excel"))
                {
                    LINEPay = await DBPMGW.LINEPay.FromSql("EXEC sp_RLP001_LINEPayReport '" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + Filter.BranchList + "'").ToListAsync();

                    totalCount = LINEPay.Count();

                    LINEPay = LINEPay.Skip(pagination.From()).Take(pagination.To()).ToList();
                    result  = LINEPay;

                    count = LINEPay.Count();
                }

                if (LineType.Equals("topup") || fileType.Equals("excel"))
                {
                    LINETopUp = await DBPMGW.LINETopUp.FromSql("EXEC sp_RLP002_LINETopUpReport '" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + Filter.BranchList + "'").ToListAsync();

                    totalCount = LINETopUp.Count();

                    LINETopUp = LINETopUp.Skip(pagination.From()).Take(pagination.To()).ToList();
                    result    = LINETopUp;

                    count = LINETopUp.Count();
                }

                if (fileType.Equals("excel"))
                {
                    return(ExportExcelLINEPay(LINEPay, LINETopUp));
                }
            }
            #endregion

            #region LINEPayRemittance
            else if (type.Equals("linetopupremittance"))
            {
                DateTime dateRemittance = DateTime.ParseExact(Filter.DateRemittance, "dd/MM/yyyy", enUS);

                string date = DateTime.Now.ToString("yyyyMMdd");



                StringBuilder sqlStringBuilder = new StringBuilder();
                sqlStringBuilder.Append("EXEC sp_RPT308_LINEPayRemittanceReport '");
                //sqlStringBuilder.Append(dateFrom.ToString("yyyyMMdd", enUS));
                //sqlStringBuilder.Append("','");
                //sqlStringBuilder.Append(dateTo.ToString("yyyyMMdd", enUS));
                //sqlStringBuilder.Append("','");
                sqlStringBuilder.Append(dateRemittance.ToString("yyyyMMdd", enUS));
                sqlStringBuilder.Append("'");

                List <LINEPayRemittance> LINEPayRemittance = await DB.LINEPayRemittance.FromSql(sqlStringBuilder.ToString()).ToListAsync();

                if (fileType.Equals("excel"))
                {
                    return(ExportExcelLINEPayRemittance(LINEPayRemittance));
                }
                else if (fileType.Equals("pdf"))
                {
                    return(ExportPdfLINEPayRemittance(LINEPayRemittance, dateRemittance));
                }

                totalCount = LINEPayRemittance.Count();

                LINEPayRemittance = LINEPayRemittance.Skip(pagination.From()).Take(pagination.To()).ToList();

                result = LINEPayRemittance;
                count  = LINEPayRemittance.Count();
            }
            #endregion

            Response.Success    = true;
            Response.Result     = result;
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = count,
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 19
0
        public async Task <ActionResult> Get(CloseShopViewModel Filter, string Type, string FileType)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            Type     = Type ?? string.Empty;
            FileType = FileType ?? string.Empty;

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US"));

            string parameter  = "'" + dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US")) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'";
            int    count      = 0;
            int    totalCount = 0;
            object result     = new List <object>();

            string EXEC = "EXEC sp_PDC_Dashboard_CloseShop_Get ";

            if (Type.Equals("confirm"))
            {
                //EXEC = "EXEC sp_RPT302_DailyRevenueConfirmed ";
            }

            string sql = EXEC + parameter;

            _logger.LogInformation(sql);

            if (Type.Equals("closeshop"))
            {
                IQueryable <CloseShop> CloseShop = DB.CloseShop.FromSql(sql);

                if (FileType.Equals("excel"))
                {
                    //return await ExportExcelVerify(DailyRevenue);
                }

                count = await CloseShop.Skip(pagination.From()).Take(pagination.To()).CountAsync();

                totalCount = CloseShop.Count();
                result     = await CloseShop.Skip(pagination.From()).Take(pagination.To()).ToListAsync();
            }
            //else if (type.Equals("confirm"))
            //{
            //    IQueryable<DailyRevenueConfirm> DailyRevenue = DB.DailyRevenueConfirm.FromSql(EXEC + parameter);

            //    if (filetype.Equals("excel"))
            //    {
            //        //return await ExportExcelConfirm(DailyRevenue);
            //    }

            //    count = await DailyRevenue.Skip(pagination.From()).Take(pagination.To()).CountAsync();
            //    totalCount = DailyRevenue.Count();
            //    result = await DailyRevenue.Skip(pagination.From()).Take(pagination.To()).ToListAsync();
            //}

            Response.Success    = true;
            Response.Result     = result;
            Response.ResultInfo = new
            {
                page    = pagination.Page,
                perPage = pagination.PerPage,
                count,
                totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
Exemplo n.º 20
0
        public async Task <ActionResult> Get(TypeBranchDateFromDateToViewModel Filter, string FileType)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            // Parameter
            string filetype = (FileType ?? "").ToLower();

            bool withReviewBalance = filetype.Equals("excelreviewbalance");

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            string parameter = $"'{ dateFrom.ToString("yyyyMMdd", enUS) }', '{ dateTo.ToString("yyyyMMdd", enUS) }', '{ UserData.Username }', '{ Filter.BranchList }'";
            string sql       = "EXEC sp_PDC_Report_DailyRevenueConfirm_Get " + parameter;

            _logger.LogInformation(sql);

            List <DailyRevenueConfirm> DailyRevenueConfirm = await DB.DailyRevenueConfirm.FromSql(sql).ToListAsync();

            if (withReviewBalance)
            {
                string[] branchList = Filter.BranchList.Split(',', StringSplitOptions.RemoveEmptyEntries);
                ReviewBalanceReport = DB.ReviewBalanceReport
                                      .Where(
                    rb => rb.ReportDate.Value >= dateFrom &&
                    rb.ReportDate <= dateTo &&
                    branchList.Contains(rb.BranchID))
                                      .OrderBy(rb => rb.OracleDC)
                                      .OrderBy(rb => rb.ReceiptDate)
                                      .ToList();
            }

            if (filetype.Equals("excel") || filetype.Equals("excelreviewbalance"))
            {
                return(ExportExcelDailyRevenueConfirm(dateFrom, dateTo, DailyRevenueConfirm, withReviewBalance, ReviewBalanceReport));
            }

            int totalCount = DailyRevenueConfirm.Count();

            DailyRevenueConfirm = DailyRevenueConfirm.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success    = true;
            Response.Result     = DailyRevenueConfirm;
            Response.ResultInfo = new
            {
                page    = pagination.Page,
                perPage = pagination.PerPage,
                count   = DailyRevenueConfirm.Count(),
                totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }
        public async Task <IActionResult> Get(ServicePointDaliyGetViewModel Filter)
        {
            if (!ModelState.IsValid)
            {
                return(Json(Response.RenderError(ModelState)));
            }

            Pagination pagination = new Pagination(HttpContext);

            // Auth Data
            var         userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value;
            UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData);

            DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS);
            DateTime dateTo   = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS);

            StringBuilder sqlStringBuilder = new StringBuilder();

            sqlStringBuilder.Append("EXEC sp_SynRTSP07_GetCommisionFee N'");
            sqlStringBuilder.Append("<dbxml>");
            sqlStringBuilder.Append("<req>");
            sqlStringBuilder.Append($"<date_from>{ dateFrom.ToString("yyyyMMdd", enUS) }</date_from>");
            sqlStringBuilder.Append($"<date_to>{ dateTo.ToString("yyyyMMdd", enUS) }</date_to>");
            sqlStringBuilder.Append($"<project_id>PSP</project_id>");
            sqlStringBuilder.Append("</req>");

            string[] profiles = (Filter.ProfileIds ?? "ALL").Split(',');

            foreach (string profile in profiles)
            {
                sqlStringBuilder.Append($"<profile><profile_id>{ profile }</profile_id></profile>");
            }

            sqlStringBuilder.Append("</dbxml>'");

            string strSQL = sqlStringBuilder.ToString();

            _logger.LogInformation(strSQL);
            List <DailyCommission> DailyCommission = await DBRTSP.DailyCommission.FromSql(strSQL)
                                                     .OrderBy(d => d.Verified)
                                                     .ToListAsync();

            if (Filter.Excel ?? false)
            {
                return(ExportExcel(DailyCommission));
            }

            int totalCount = DailyCommission.Count();

            DailyCommission = DailyCommission.Skip(pagination.From()).Take(pagination.To()).ToList();

            Response.Success = true;
            Response.Result  = DailyCommission.Select(c => new {
                id = $"{c.ProfileId}-{c.ReportDate.ToString("yyyyMMdd", enUS)}",
                c.ProfileId,
                c.ReportDate,
                c.ProfileName,
                c.BranchId,
                c.Consignment,
                c.Boxes,
                c.Cash,
                c.Verified
            });
            Response.ResultInfo = new
            {
                page       = pagination.Page,
                perPage    = pagination.PerPage,
                count      = DailyCommission.Count(),
                totalCount = totalCount
            };

            DB.Dispose();

            return(Json(Response.Render()));
        }