Ejemplo n.º 1
0
        public async Task <IActionResult> AddReceiptItem(NewReceiptItem newreceipt)
        {
            bool isAdded = await _eventService.AddReceiptItem(newreceipt);

            if (isAdded)
            {
                return(Ok(new { Status = "OK", Message = "Poprawnie dodano nową pozycje" }));
            }
            return(Ok(new { Status = "Exists", Message = "Już taka pozycja jest na paragonie" }));
        }
Ejemplo n.º 2
0
        public async Task <bool> AddReceiptItem(NewReceiptItem receiptItem)
        {
            bool CheckExists(int participant, int amount, string name, double price)
            {
                int a = _context.ReceiptItems.Count(x => (x.ParticipantId == participant) && (x.Price == price) && (x.ProductName == name));

                return(a == 0 ? false : true);
            }

            var a = await _context.Participants.FirstAsync(x => x.Id == receiptItem.Participant);

            if (CheckExists(receiptItem.Participant, receiptItem.Count, receiptItem.PositionName, receiptItem.Value))
            {
                return(false);
            }

            _context.ReceiptItems.Add(new ReceiptItem()
            {
                Amount = receiptItem.Count, ParticipantId = receiptItem.Participant, Price = receiptItem.Value, ProductName = receiptItem.PositionName
            });
            await _context.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 3
0
 public Task <bool> AddReceipt(NewReceiptItem item)
 {
     throw new NotImplementedException();
 }