示例#1
0
        public ActionResult Post([FromBody] IdAmount[] productAmounts)
        {
            User user     = GetClaimUser();
            var  products =
                (from p in db.Product
                 from pa in productAmounts
                 where pa.Id == p.Id
                 select new ProductAmountPrice()
            {
                ProductInfo = p,
                Amount = pa.Amount
            }).ToArray();

            ProductCalc pricing;

            if (user != null && user.DiscountPoints == 10)
            {
                pricing = new ProductCalc(discountPercentage);
            }
            else
            {
                pricing = new ProductCalc(0.00m);
            }
            pricing.calcPrice(products);

            return(Ok(new {
                discountAmount = pricing.DiscountAmount,
                discountPercentage = pricing.DiscountPercentage,
                tax = pricing.Tax,
                totalPrice = pricing.TotalPrice,
                grandTotal = pricing.GrandTotal
            }));
        }
示例#2
0
        public static ProductivityData DataTableToProductivityData(DataTable dtTotalCLS, DataTable dtProRNPN, string year)
        {
            ProductivityData        proData     = new ProductivityData();
            List <ProductivityRNPN> proRNPNList = new List <ProductivityRNPN>();
            ProductivityRNPN        proRNPN     = null;
            List <ProductivityWard> proWardList = new List <ProductivityWard>();
            ProductivityWard        proWard     = null;
            ProductCalc             proCalcRN   = null;
            ProductCalc             proCalcPN   = null;

            proData.Year = year;

            foreach (DataRow rowTotalCLS in dtTotalCLS.Rows)
            {
                proRNPN   = new ProductivityRNPN();
                proCalcRN = new ProductCalc();
                proWard   = new ProductivityWard();
                proCalcPN = new ProductCalc();

                string month = string.Empty;
                if (month != rowTotalCLS["Month"].ToString())
                {
                    proRNPN.Month = rowTotalCLS["Month"].ToString();
                }


                decimal totalCLSRN     = Convert.ToDecimal(rowTotalCLS["TotalCLSRN"].ToString());
                decimal totalCLSPN     = Convert.ToDecimal(rowTotalCLS["TotalCLSPN"].ToString());
                decimal totalNurseX7RN = 0;
                decimal totalNurseX7PN = 0;


                foreach (DataRow rowProRNPN in dtProRNPN.Rows)
                {
                    proCalcRN = new ProductCalc();
                    proCalcPN = new ProductCalc();
                    if (rowTotalCLS["Month"].ToString() == rowProRNPN["Month"].ToString())
                    {
                        if (rowTotalCLS["WRD"].ToString() == rowProRNPN["GWard"].ToString())
                        {
                            proWard.Ward = rowTotalCLS["WRD"].ToString();

                            // RN
                            totalNurseX7RN           = Convert.ToDecimal(rowProRNPN["TotalNurseX7RN"].ToString());
                            proCalcRN.TotalCLS       = totalCLSRN;
                            proCalcRN.TotalNurse     = Convert.ToDecimal(rowProRNPN["TotalNurseRN"].ToString());
                            proCalcRN.TotalHourNurse = totalNurseX7RN;
                            proCalcRN.Percent        = GetPercent(totalCLSRN, totalNurseX7RN);

                            // PN
                            totalNurseX7PN           = Convert.ToDecimal(rowProRNPN["TotalNursePN"].ToString());
                            proCalcPN.TotalCLS       = totalCLSPN;
                            proCalcPN.TotalNurse     = Convert.ToDecimal(rowProRNPN["TotalNursePN"].ToString());
                            proCalcPN.TotalHourNurse = totalNurseX7PN;
                            proCalcPN.Percent        = GetPercent(totalCLSPN, totalNurseX7PN);

                            proWard.ProductCalcRN = proCalcRN;
                            proWard.ProductCalcPN = proCalcPN;
                        }
                    }

                    proWardList.Add(proWard);
                }

                proRNPNList.Add(proRNPN);
            }

            proData.ProductivityRNPNList = proRNPNList;

            return(proData);
        }