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;
            }
        }
Example #2
0
        private void UpdateSalesOrder(int salesOrderId)
        {
            try
            {
                SalesOrder salesOrder = new SalesOrder();
                salesOrder = _functionalService.GetById <SalesOrder>(salesOrderId);

                if (salesOrder != null)
                {
                    List <SalesOrderLine> lines = new List <SalesOrderLine>();
                    lines = _functionalService.GetList <SalesOrderLine>()
                            .Where(x => x.SalesOrderId.Equals(salesOrder.SalesOrderId))
                            .ToList();

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

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

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

                    _functionalService.Update <SalesOrder>(salesOrder);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public IActionResult Crud([FromBody] ScheduleViewModel <BookGeneralViewModel> payload)
        {
            if (payload.added.Count > 0)
            {
                BookGeneralViewModel value       = payload.added[0];
                BookGeneral          bookGeneral = new BookGeneral();
                value.BookGeneralId = 0;
                _mapper.Map <BookGeneralViewModel, BookGeneral>(value, bookGeneral);
                _functionalService.Insert <BookGeneral>(bookGeneral);
            }
            if (payload.changed.Count > 0)
            {
                BookGeneralViewModel value = payload.changed[0];
                _functionalService.Update <BookGeneralViewModel, BookGeneral>(value, Convert.ToInt32(value.BookGeneralId));
            }
            if (payload.deleted.Count > 0)
            {
                BookGeneralViewModel value = payload.deleted[0];
                var result = _functionalService.Delete <BookGeneral>(Convert.ToInt32(value.BookGeneralId));
            }

            List <BookGeneral> books = _functionalService.GetList <BookGeneral>().ToList();

            return(Ok(books));
        }
Example #4
0
        public async Task <IActionResult> Crud([FromBody] ScheduleViewModel <MyAgendaViewModel> payload)
        {
            if (payload.added.Count > 0)
            {
                MyAgendaViewModel value    = payload.added[0];
                MyAgenda          MyAgenda = new MyAgenda();
                value.MyAgendaId = 0;
                _mapper.Map <MyAgendaViewModel, MyAgenda>(value, MyAgenda);
                _functionalService.Insert <MyAgenda>(MyAgenda);
            }
            if (payload.changed.Count > 0)
            {
                MyAgendaViewModel value = payload.changed[0];
                _functionalService.Update <MyAgendaViewModel, MyAgenda>(value, Convert.ToInt32(value.MyAgendaId));
            }
            if (payload.deleted.Count > 0)
            {
                MyAgendaViewModel value = payload.deleted[0];
                var result = _functionalService.Delete <MyAgenda>(Convert.ToInt32(value.MyAgendaId));
            }

            ApplicationUser appUser = await _userManager.GetUserAsync(User);

            List <MyAgenda> books = new List <MyAgenda>();

            if (appUser != null)
            {
                books = _functionalService.GetList <MyAgenda>()
                        .Where(x => x.CreateBy.Equals(appUser.Id)).ToList();
            }
            return(Ok(books));
        }
Example #5
0
        public IActionResult Update([FromBody] CrudViewModel <UserProfile> payload)
        {
            UserProfile profile = payload.value;

            _functionalService.Update <UserProfile>(profile);
            return(Ok(profile));
        }
Example #6
0
        public IActionResult Update([FromBody] CrudViewModel <CashBankViewModel> payload)
        {
            CashBankViewModel value = payload.value;
            var result = _functionalService
                         .Update <CashBankViewModel, CashBank>(value, Convert.ToInt32(value.CashBankId));

            return(Ok());
        }
Example #7
0
        public IActionResult Update([FromBody] CrudViewModel <BillViewModel> payload)
        {
            BillViewModel value  = payload.value;
            var           result = _functionalService
                                   .Update <BillViewModel, Bill>(value, Convert.ToInt32(value.BillId));

            return(Ok());
        }
Example #8
0
        public IActionResult Update([FromBody] CrudViewModel <UnitOfMeasureViewModel> payload)
        {
            UnitOfMeasureViewModel value = payload.value;
            var result = _functionalService
                         .Update <UnitOfMeasureViewModel, UnitOfMeasure>(value, Convert.ToInt32(value.UnitOfMeasureId));

            return(Ok());
        }
        public IActionResult Update([FromBody] CrudViewModel <GoodsReceivedNoteViewModel> payload)
        {
            GoodsReceivedNoteViewModel value = payload.value;
            var result = _functionalService
                         .Update <GoodsReceivedNoteViewModel, GoodsReceivedNote>(value, Convert.ToInt32(value.GoodsReceivedNoteId));

            return(Ok());
        }
        public IActionResult Update([FromBody] CrudViewModel <InvoiceViewModel> payload)
        {
            InvoiceViewModel value = payload.value;
            var result             = _functionalService
                                     .Update <InvoiceViewModel, Invoice>(value, Convert.ToInt32(value.InvoiceId));

            return(Ok());
        }
Example #11
0
        public IActionResult Update([FromBody] CrudViewModel <ShipmentViewModel> payload)
        {
            ShipmentViewModel value = payload.value;
            var result = _functionalService
                         .Update <ShipmentViewModel, Shipment>(value, Convert.ToInt32(value.ShipmentId));

            return(Ok());
        }
        public IActionResult Update([FromBody] CrudViewModel <MeetingRoomViewModel> payload)
        {
            MeetingRoomViewModel value = payload.value;
            var result = _functionalService
                         .Update <MeetingRoomViewModel, MeetingRoom>(value, Convert.ToInt32(value.MeetingRoomId));

            return(Ok());
        }
Example #13
0
        public IActionResult Update([FromBody] CrudViewModel <WarehouseViewModel> payload)
        {
            WarehouseViewModel value = payload.value;
            var result = _functionalService
                         .Update <WarehouseViewModel, Warehouse>(value, Convert.ToInt32(value.WarehouseId));

            return(Ok());
        }
Example #14
0
        public IActionResult Update([FromBody] CrudViewModel <CustomerTypeViewModel> payload)
        {
            CustomerTypeViewModel value = payload.value;
            var result = _functionalService
                         .Update <CustomerTypeViewModel, CustomerType>(value, Convert.ToInt32(value.CustomerTypeId));

            return(Ok());
        }
        public IActionResult Update([FromBody] CrudViewModel <PaymentReceiveViewModel> payload)
        {
            PaymentReceiveViewModel value = payload.value;
            var result = _functionalService
                         .Update <PaymentReceiveViewModel, PaymentReceive>(value, Convert.ToInt32(value.PaymentReceiveId));

            return(Ok());
        }
        public IActionResult Update([FromBody] CrudViewModel <VendorViewModel> payload)
        {
            VendorViewModel value  = payload.value;
            var             result = _functionalService
                                     .Update <VendorViewModel, Vendor>(value, Convert.ToInt32(value.VendorId));

            return(Ok());
        }
Example #17
0
        public IActionResult Update([FromBody] CrudViewModel <ProductViewModel> payload)
        {
            ProductViewModel value = payload.value;

            value.Barcode = value.Barcode.ToUpper();
            var result = _functionalService
                         .Update <ProductViewModel, Product>(value, Convert.ToInt32(value.ProductId));

            return(Ok());
        }