Пример #1
0
        /**
         * GET request that get one sales
         */
        public sale GetSaleById(int id)
        {
            MedicinesbySalesRepository msrep = new MedicinesbySalesRepository();
            var  query = "SELECT * FROM getsale(" + id + ");";
            sale sal   = _context.Database.SqlQuery <sale>(query).FirstOrDefault();

            sal.medicines = msrep.GetMedicinebySaleBySale(sal.id_sale);
            return(sal);
        }
Пример #2
0
        /**
         * GET request that get sales by payment type
         */
        public sale_by_payment_type GetSalesByPaymentType(int sub, int cash, DateTime date)
        {
            MedicinesbySalesRepository msrep = new MedicinesbySalesRepository();
            sale_by_payment_type       spt   = new sale_by_payment_type();
            var query = "SELECT * FROM getsalebypayment(" + sub + "," + cash + "," + 1 + ",'" + date + "')";

            spt.credit = _context.Database.SqlQuery <sale>(query).ToList();
            var query2 = "SELECT * FROM getsalebypayment(" + sub + "," + cash + "," + 2 + ",'" + date + "')";

            spt.cash = _context.Database.SqlQuery <sale>(query2).ToList();
            for (int i = 0; i < spt.credit.Count(); i++)
            {
                spt.credit[i].medicines = msrep.GetMedicinebySaleBySale(spt.credit[i].id_sale);
            }
            for (int i = 0; i < spt.cash.Count(); i++)
            {
                spt.cash[i].medicines = msrep.GetMedicinebySaleBySale(spt.cash[i].id_sale);
            }
            return(spt);
        }
Пример #3
0
        /**
         * GET request that get all sales
         */
        public List <sale> GetAllSales()
        {
            MedicinesbySalesRepository msrep = new MedicinesbySalesRepository();
            var         query = "SELECT * FROM getsales()";
            List <sale> sal   = _context.Database.SqlQuery <sale>(query).ToList();

            for (int i = 0; i < sal.Count(); i++)
            {
                sal[i].medicines = msrep.GetMedicinebySaleBySale(sal[i].id_sale);
            }
            return(sal);
        }