Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            naslov.InnerText = "RAČUN ZA STO BROJ ";
            radnik.InnerText = "Radnik: " + WorkerBusiness.currentWoker.User_Name;
            naslov.Style.Add("color", "#a37417");
            naslov.Style.Add("font-size", "3.5rem");
            naslov.Style.Add("font-family", "times new roman");
            naslov.InnerHtml += $"<span style='color:black;'> {TableBusiness.curentTable.Table_ID}</span>";
            Label1.Text       = "Total: " + BillBusiness.currentBill.Total_Price.ToString() + " RSD";

            ArticleRepository  ab  = new ArticleRepository();
            BillItemRepository bib = new BillItemRepository();
            BillBusiness       br  = new BillBusiness();

            cb = bib.GetCaffeBillItems().Where(x => x.Bill_ID == br.GetCaffeBill.Bill_ID).ToList();

            foreach (CaffeBillItem c in cb)
            {
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.Style.Add("font-size", "1.3rem");
                par.Style.Add("font-family", "Times New Roman");
                par.InnerText = ab.GetCaffeArticles().Where(x => x.Article_ID == c.Article_ID).ToList()[0].ToString() + "   x" + c.Quantity;
                contentmain.Controls.Add(par);
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post(BillItem billItem)
        {
            if (billItem == null)
            {
                return(BadRequest(StatusCodes.Status400BadRequest));
            }
            BillItemRepository.Add(billItem);
            await UnitOfWork.SaveAsync();

            return(Ok(new { Code = 200 }));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetbyDate(DateTime dateTime)
        {
            var billItems = await BillItemRepository.GetByDateAsync(dateTime);

            BillItemList vm = new BillItemList();

            vm.BillItems = billItems;
            vm.totleNum  = billItems.Sum(c => c.ProductNumber);
            vm.amount    = billItems.Sum(c => c.ProductNumber * c.Price);
            return(Ok(vm));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> DeleteById(int id)
        {
            if (id < 1)
            {
                return(BadRequest(StatusCodes.Status400BadRequest));
            }
            await BillItemRepository.DeleteById(id);

            await UnitOfWork.SaveAsync();

            return(Ok(new { Code = 200 }));
        }
Ejemplo n.º 5
0
        protected override Bill DoPostPutDto(Client currentClient, BillDTO dto, Bill entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new Bill();
            }
            GetMapper.Map(dto, entity);
            if (dto.Booking != null && dto.Booking.Id != 0)
            {
                entity.Booking = BookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Booking, currentClient, path);
            }
            if (dto.BillItems != null)
            {
                BillItemRepository.DeleteRange(entity.BillItems.Where(d => !dto.BillItems.Any(x => x.Id == d.Id)));
                dto.BillItems.ForEach(bitem =>
                {
                    if (entity.BillItems.Count != 0 && bitem.Id != 0 &&
                        entity.BillItems.Find(p => p.Id == bitem.Id) != null)
                    {
                        return;
                    }
                    BillItem toAdd = BillItemService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, bitem, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.BillItems.Add(toAdd);
                    }
                });
            }
            if (dto.PaymentMethods != null)
            {
                PaymentMethodRepository.DeleteRange(entity.PaymentMethods.Where(d => !dto.PaymentMethods.Any(x => x.Id == d.Id)));
                dto.PaymentMethods.ForEach(pm =>
                {
                    if (entity.PaymentMethods.Count != 0 && pm.Id != 0 &&
                        entity.PaymentMethods.Find(p => p.Id == pm.Id) != null)
                    {
                        return;
                    }
                    PaymentMethod toAdd = PaymentMethodService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, pm, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.PaymentMethods.Add(toAdd);
                    }
                });
            }
            if (dto.Supplier != null)
            {
                entity.Supplier = SupplierService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Supplier, currentClient, path);
            }
            return(entity);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Get()
        {
            //string conStr = Configuration["user:name"];
            //throw new Exception("xxxxxxxxxxx");
            var billItems = await BillItemRepository.GetAllAsync();

            BillItemList vm = new BillItemList();

            vm.BillItems = billItems;
            vm.totleNum  = billItems.Sum(c => c.ProductNumber);
            vm.amount    = billItems.Sum(c => c.ProductNumber * c.Price);
            return(Ok(vm));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> GetAnalysisByMonth(int month)
        {
            if (month > 12 || month < 1)
            {
                return(BadRequest(StatusCodes.Status400BadRequest));
            }
            var billItems = await BillItemRepository.GetByMonthAsync(month);

            var Analysis = billItems.GroupBy(c => c.CreationDate.Date).Select(bill => new
            {
                date = bill.Key,
                num  = bill.Sum(c => c.ProductNumber)
            }).ToList();

            return(Ok(Analysis));
        }
Ejemplo n.º 8
0
 public override void ProcessDTOPostPut(BillItemDTO dto, int id, Client currentClient)
 {
     orig = BillItemRepository.GetBillItemById(dto == null ? id : (int)dto.Id, currentClient.Id);
 }
Ejemplo n.º 9
0
 public BillItemBusiness()
 {
     this.billItemRepository = new BillItemRepository();
 }
Ejemplo n.º 10
0
 public void Init()
 {
     ctx  = EFContext.CreateContext();
     repo = new BillItemRepository(ctx);
 }
Ejemplo n.º 11
0
        protected void dodaj_ServerClick(object sender, EventArgs e)
        {
            ArticleRepository  ab       = new ArticleRepository();
            BillItemRepository billItem = new BillItemRepository();
            BillBusiness       bp       = new BillBusiness();
            String             s        = toplinapici.Value;

            if (s != null && s != "Topli napici")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            String s1 = zestina.Value;

            if (s1 != null && s1 != "Žestina")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s1)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            String s2 = Pivo.Value;

            if (s2 != null && s2 != "Pivo")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s2)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            String s3 = bezalkohola.Value;

            if (s3 != null && s3 != "Bezalkoholna pića")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s3)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            Response.Redirect("Bill.aspx");
        }
Ejemplo n.º 12
0
 public void init()
 {
     c  = new CaffeBillItem(4, 5204, 8);
     cr = new BillItemRepository();
 }
Ejemplo n.º 13
0
 public void Init()
 {
     ctx = EFContext.CreateContext();
     repo = new BillItemRepository(ctx);
 }