Example #1
0
        private void UpdatePurchaseOrder(int purchaseOrderId)
        {
            try
            {
                PurchaseOrder purchaseOrder = new PurchaseOrder();
                purchaseOrder = _functionalService.GetById <PurchaseOrder>(purchaseOrderId);

                if (purchaseOrder != null)
                {
                    List <PurchaseOrderLine> lines = new List <PurchaseOrderLine>();
                    lines = _functionalService.GetList <PurchaseOrderLine>()
                            .Where(x => x.PurchaseOrderId.Equals(purchaseOrderId))
                            .ToList();

                    //update master data by its lines
                    purchaseOrder.Amount   = lines.Sum(x => x.Amount);
                    purchaseOrder.SubTotal = lines.Sum(x => x.SubTotal);

                    purchaseOrder.Discount = lines.Sum(x => x.DiscountAmount);
                    purchaseOrder.Tax      = lines.Sum(x => x.TaxAmount);

                    purchaseOrder.Total = purchaseOrder.Freight + lines.Sum(x => x.Total);

                    _functionalService.Update <PurchaseOrder>(purchaseOrder);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public IActionResult GetByBranchId([FromRoute] int id)
        {
            Branch   branch   = new Branch();
            Currency currency = new Currency();

            branch = _functionalService.GetById <Branch>(id);
            if (branch != null && branch.CurrencyId != 0)
            {
                currency = _functionalService.GetById <Currency>(branch.CurrencyId);
            }
            return(Ok(currency));
        }
Example #3
0
        public IActionResult GetById([FromRoute] int id)
        {
            Product product = new Product();

            product = _functionalService.GetById <Product>(id);
            return(Ok(product));
        }
Example #4
0
        public IActionResult GetSalesOrderLineByShipmentId()
        {
            var      headers            = Request.Headers["ShipmentId"];
            int      shipmentId         = Convert.ToInt32(headers);
            Shipment shipment           = _functionalService.GetById <Shipment>(shipmentId);
            List <SalesOrderLine> Items = new List <SalesOrderLine>();

            if (shipment != null)
            {
                int salesOrderId = shipment.SalesOrderId;
                Items = _functionalService.GetList <SalesOrderLine>()
                        .Where(x => x.SalesOrderId.Equals(salesOrderId))
                        .ToList();
            }
            int Count = Items.Count();

            return(Ok(new { Items, Count }));
        }
Example #5
0
        public IActionResult GetAmount([FromRoute] int id)
        {
            var  Amount = 0.0;
            Bill bill   = _functionalService.GetById <Bill>(id);

            if (bill != null)
            {
                GoodsReceivedNote grn = _functionalService.GetById <GoodsReceivedNote>(bill.GoodsReceivedNoteId);
                if (grn != null)
                {
                    PurchaseOrder purchaseOrder = _functionalService.GetById <PurchaseOrder>(grn.PurchaseOrderId);
                    if (purchaseOrder != null)
                    {
                        Amount = purchaseOrder.Total;
                    }
                }
            }
            return(Ok(new { Amount }));
        }
        public IActionResult GetAmount([FromRoute] int id)
        {
            var     Amount  = 0.0;
            Invoice invoice = _functionalService.GetById <Invoice>(id);

            if (invoice != null)
            {
                Shipment shipment = _functionalService.GetById <Shipment>(invoice.ShipmentId);
                if (shipment != null)
                {
                    SalesOrder salesOrder = _functionalService.GetById <SalesOrder>(shipment.SalesOrderId);
                    if (salesOrder != null)
                    {
                        Amount = salesOrder.Total;
                    }
                }
            }
            return(Ok(new { Amount }));
        }
Example #7
0
        public async Task <IActionResult> Remove([FromBody] CrudViewModel <UserProfile> payload)
        {
            int key         = Convert.ToInt32(payload.key);
            var userProfile = _functionalService.GetById <UserProfile>(key);

            if (userProfile != null)
            {
                var user = await _userManager.FindByIdAsync(userProfile.ApplicationUserId);

                var result = await _userManager.DeleteAsync(user);

                if (result.Succeeded)
                {
                    _functionalService.Delete <UserProfile>(userProfile);
                }
            }

            return(Ok());
        }
        public IActionResult GetById(int id)
        {
            PurchaseOrder result = _functionalService.GetById <PurchaseOrder>(id);

            return(Ok(result));
        }
Example #9
0
        public IActionResult GetById(int id)
        {
            SalesOrder result = _functionalService.GetById <SalesOrder>(id);

            return(Ok(result));
        }