Beispiel #1
0
        // URL: Persons/Edit
        public async System.Threading.Tasks.Task <ActionResult> Edit(System.Guid id)
        {
            // person = personBL.GetPersonByPersonID(id);


            //Creating object of Person into PersonViewModel
            RawMaterialOrderViewModel rawMaterialOrderViewModel = new RawMaterialOrderViewModel();
            RawMaterialOrderBL        rawMaterialOrderBL        = new RawMaterialOrderBL();
            RawMaterialBL             rawMaterialBL             = new RawMaterialBL();
            SupplierBL supplierBL = new SupplierBL();

            //Creating object of Person EntityModel
            Rawmaterialorder1        rawMaterialOrder  = new Rawmaterialorder1();
            RawMaterial              rawMaterial       = new RawMaterial();
            Supplier                 supplier          = new Supplier();
            List <Rawmaterialorder1> rawMaterialOrders = await rawMaterialOrderBL.GetAllRawMaterialOrdersBL();

            rawMaterial.RawMaterialName               = rawMaterialOrderViewModel.RawMaterialName;
            supplier.SupplierName                     = rawMaterialOrderViewModel.SupplierName;
            rawMaterialOrder.RawMaterialTotalPrice    = Convert.ToDecimal(rawMaterialOrderViewModel.RawMaterialTotalPrice);
            rawMaterialOrder.RawMaterialTotalQuantity = Convert.ToDecimal(rawMaterialOrderViewModel.RawMaterialTotalQuantity);

            //Getting list of persons from PersonsBL
            ;

            //Add Persons to ViewBag
            ViewBag.PersonsList = new SelectList(rawMaterialOrders, "PersonID", "PersonName");

            return(View(rawMaterialOrderViewModel));
        }
        public static async Task DeleteOrder()
        {
            try
            {
                using (RawMaterialOrderBL RawMaterialorderBL = new RawMaterialOrderBL())
                {
                    //Read Sl.No
                    Write("Order #: ");
                    bool isNumberValid = int.TryParse(ReadLine(), out int serial);
                    if (isNumberValid)
                    {
                        serial--;
                        List <RawMaterialOrder> RawMaterialorders = await RawMaterialorderBL.GetAllRawMaterialOrdersBL();

                        if (serial <= RawMaterialorders.Count - 1)
                        {
                            //Confirmation
                            RawMaterialOrder RawMaterialorder = RawMaterialorders[serial];
                            Write("Are you sure? (Y/N): ");
                            string confirmation = ReadLine();

                            if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase))
                            {
                                //Invoke DeleteSupplierBL method to delete
                                bool isDeleted = await RawMaterialorderBL.DeleteRawMaterialOrderBL(RawMaterialorder.RawMaterialOrderID);

                                if (isDeleted)
                                {
                                    WriteLine("Order Deleted");
                                }
                                RawMaterialOrderDetailBL      RawMaterialorderDetailBL = new RawMaterialOrderDetailBL();
                                List <RawMaterialOrderDetail> detailsList = await RawMaterialorderDetailBL.GetAllRawMaterialOrderDetailsBL();

                                foreach (RawMaterialOrderDetail item in detailsList)
                                {
                                    if (item.RawMaterialOrderID == RawMaterialorder.RawMaterialOrderID)
                                    {
                                        await RawMaterialorderDetailBL.DeleteRawMaterialOrderDetailBL(item.RawMaterialOrderDetailID);
                                    }
                                }
                            }
                        }
                        else
                        {
                            WriteLine($"Invalid Order #.\nPlease enter a number between 1 to {RawMaterialorders.Count}");
                        }
                    }
                    else
                    {
                        WriteLine($"Invalid number.");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }
Beispiel #3
0
        public async System.Threading.Tasks.Task <ActionResult> Index()
        {
            //Creating object of PersonsBL
            RawMaterialOrderBL rawMaterialOrderBL = new RawMaterialOrderBL();
            SupplierBL         supplierBL         = new SupplierBL();


            RawMaterialBL      rawMaterialBL = new RawMaterialBL();
            List <RawMaterial> rawMaterials  = await rawMaterialBL.GetAllRawMaterialsBL();

            ViewBag.list1 = new SelectList(rawMaterials, "RawMaterialName");

            //Getting list of persons from PersonsBL
            List <Rawmaterialorder1> rawMaterialOrders = await rawMaterialOrderBL.GetAllRawMaterialOrdersBL();

            //Create an empty collection of PersonViewModel
            List <RawMaterialOrderViewModel> rawMaterialOrderViewModel = new List <RawMaterialOrderViewModel>();

            //ServiceReference1.RawMaterialOrderServiceClient personsServiceClient = new ServiceReference1.RawMaterialOrderServiceClient();
            //ServiceReference1.RawMaterialOrderDataContract[] rawMaterialOrderDataContracts = personsServiceClient.GetAllRawMaterialOrder();
            ////Migrate (copy) data from EntityModel collection to ViewModel collection
            foreach (var item in rawMaterialOrders)
            {
                Supplier suppl = await supplierBL.GetSupplierBySupplierIDBL(item.SupplierID);

                RawMaterialOrderViewModel rawMaterialOrderVM = new RawMaterialOrderViewModel()
                {
                    //RawMaterialOrderID = item.RawMaterialOrderID,
                    //SupplierID = Convert.ToString(item.SupplierID),

                    RawMaterialOrderID = item.RawMaterialOrderID,

                    SupplierName             = suppl.SupplierName,
                    RawMaterialTotalPrice    = Convert.ToDouble(item.RawMaterialTotalPrice),
                    RawMaterialTotalQuantity = Convert.ToDouble(item.RawMaterialTotalQuantity)
                };
                rawMaterialOrderViewModel.Add(rawMaterialOrderVM);
            }

            //Call view & pass personVM collection to view
            return(View(rawMaterialOrderViewModel));
        }
        public static async Task ViewOrder()
        {
            try
            {
                Supplier    Supplier   = new Supplier();
                ISupplierBL SupplierBL = new SupplierBL();

                Supplier = await SupplierBL.GetSupplierByEmailBL(CommonData.CurrentUser.Email);

                using (RawMaterialOrderBL RawMaterialorderdetailBL = new RawMaterialOrderBL())
                {
                    //Get and display list of system users.
                    List <RawMaterialOrder> details = await RawMaterialorderdetailBL.GetAllRawMaterialOrdersBL();

                    int serial = 0;

                    WriteLine("Orders:");
                    if (details != null && details?.Count > 0)
                    {
                        WriteLine("#\tRawMaterialOrderID\tRawMaterialTotalPrice\t SupplierID\tRawMaterialTotalQuantity\tRawMaterialOrderDate\tCreationDateTime\tLastmodifiedDateTime");
                        foreach (RawMaterialOrder item in details)
                        {
                            if (item.SupplierID == Supplier.SupplierID)
                            {
                                serial++;
                                WriteLine($"{serial}\t{item.RawMaterialOrderID}\t{item.RawMaterialTotalPrice}\t{item.RawMaterialTotalQuantity}\t{item.SupplierID}\t{item.RawMaterialOrderDate}\t{item.CreationDateTime}\t{item.LastmodifiedDateTime}");
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }