Exemplo n.º 1
0
        public object UpdatePOSSaleItemQuantity(string Id, int quantity)
        {
            POSSaleItem possaleItem = possaleItemContext.Find(Id);

            if (possaleItem != null)
            {
                try
                {
                    possaleItem.ModifiedAt = DateTime.Now;
                    possaleItem.Quantity   = quantity;
                    possaleItemContext.Update(possaleItem);
                    possaleItemContext.Commit();
                    return(new { Successful = true, Message = "Item update succeeded." });
                }
                catch (Exception ex)
                {
                    // log error
                    Console.WriteLine(ex);

                    // send message
                    return(new { Successful = false, Message = "Item update failed." });
                }
            }
            else
            {
                return(new { Successful = false, Message = "Item not found." });
            }
        }
Exemplo n.º 2
0
        public object UpdatePOSSaleItem(string Id, string productDescription, int quantity, decimal price)
        {
            POSSaleItem invoiceItem = possaleItemContext.Find(Id);

            if (invoiceItem != null)
            {
                try
                {
                    decimal oldPrice = invoiceItem.Price;
                    invoiceItem.ProductDescription = productDescription;
                    invoiceItem.Quantity           = quantity;
                    invoiceItem.Price      = price;
                    invoiceItem.ModifiedAt = DateTime.Now;
                    possaleItemContext.Update(invoiceItem);
                    possaleItemContext.Commit();
                    return(new { Successful = true, Message = "Item update succeeded.", OldValue = oldPrice });
                }
                catch (Exception ex)
                {
                    // log error
                    Console.WriteLine(ex);

                    // send message
                    return(new { Successful = false, Message = "Item update failed." });
                }
            }
            else
            {
                return(new { Successful = false, Message = "Item not found." });
            }
        }
        public POSTransactionSummaryViewModel GetPOSTransactionSummary(HttpContextBase httpContext)
        {
            POSTransaction posTransaction        = GetPOSTransaction(httpContext, false);
            POSTransactionSummaryViewModel model = new POSTransactionSummaryViewModel(0, 0);

            if (posTransaction != null)
            {
                int?transactionCount = (from item in posTransaction.POSTransactionItems
                                        select item.Quantity).Sum();
                decimal?transactionTotal = (from pi in posTransaction.POSTransactionItems
                                            join p in productContext.Collection() on pi.ProductId equals p.Id
                                            select pi.Quantity *p.Price).Sum();
                model.TransactionCount = transactionCount ?? 0;
                model.TransactionTotal = transactionTotal ?? decimal.Zero;

                foreach (var item in posTransaction.POSTransactionItems)
                {
                    POSSaleItem possaleItem = new POSSaleItem()
                    {
                        ProductId          = item.ProductId,
                        ProductName        = item.ProductName,
                        ProductDescription = item.ProductDescription,
                        Image    = item.Image,
                        Price    = item.Price,
                        Quantity = item.Quantity
                    };
                    model.POSSaleItems.Add(possaleItem);
                }
            }
            return(model);
        }
Exemplo n.º 4
0
        public object RemoveItemFromPOSSale(string Id)
        {
            POSSaleItem itemToDelete = possaleItemContext.Find(Id);

            if (itemToDelete == null)
            {
                return(new { Successful = false, Message = "Item '" + Id + "' not  found.", ItemId = "" });
            }
            else
            {
                possaleItemContext.Delete(Id);
                possaleItemContext.Commit();
                return(new { Successful = true, Message = "Item deleted.", ItemId = Id });
            }
        }