/// <summary> /// Displays list of Suppliers. /// </summary> /// <returns></returns> public static async Task ViewSuppliers() { try { using (ISupplierBL supplierBL = new SupplierBL()) { //Get and display list of system users. List <Supplier> suppliers = await supplierBL.GetAllSuppliersBL(); WriteLine("SUPPLIERS:"); if (suppliers != null && suppliers?.Count > 0) { WriteLine("#\tName\tMobile\tEmail\tCreated\tModified"); int serial = 0; foreach (var supplier in suppliers) { serial++; WriteLine($"{serial}\t{supplier.SupplierName}\t{supplier.SupplierMobile}\t{supplier.Email}\t{supplier.CreationDateTime}\t{supplier.LastModifiedDateTime}"); } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
private static void ListAllSuppliersBL() { try { List <Supplier> supplierList = SupplierBL.GetAllSuppliersBL(); if (supplierList != null) { Console.WriteLine("******************************************************************************"); Console.WriteLine("SupplierID\t\tSupplierName\t\tAddressID\t\tMobile\t\tSupplierEmail"); Console.WriteLine("******************************************************************************"); foreach (Supplier supplier in supplierList) { Console.WriteLine("{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}", supplier.SupplierID, supplier.SupplierName, supplier.AddressID, supplier.SupplierMobile, supplier.SupplierEmail); } Console.WriteLine("******************************************************************************"); } else { Console.WriteLine("No Supplier Details Available"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Updates Supplier. /// </summary> /// <returns></returns> public static async Task UpdateSupplier() { try { using (ISupplierBL supplierBL = new SupplierBL()) { //Read Sl.No Write("Supplier #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; List <Supplier> suppliers = await supplierBL.GetAllSuppliersBL(); if (serial <= suppliers.Count - 1) { //Read inputs Supplier supplier = suppliers[serial]; Write("Name: "); supplier.SupplierName = ReadLine(); Write("Mobile: "); supplier.SupplierMobile = ReadLine(); Write("Email: "); supplier.Email = ReadLine(); //Invoke UpdateSupplierBL method to update bool isUpdated = await supplierBL.UpdateSupplierBL(supplier); if (isUpdated) { WriteLine("Supplier Updated"); } } else { WriteLine($"Invalid Supplier #.\nPlease enter a number between 1 to {suppliers.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
/// <summary> /// Delete Supplier. /// </summary> /// <returns></returns> public static async Task DeleteSupplier() { try { using (ISupplierBL supplierBL = new SupplierBL()) { //Read Sl.No Write("Supplier #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; List <Supplier> suppliers = await supplierBL.GetAllSuppliersBL(); if (serial <= suppliers.Count - 1) { //Confirmation Supplier supplier = suppliers[serial]; Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { //Invoke DeleteSupplierBL method to delete bool isDeleted = await supplierBL.DeleteSupplierBL(supplier.SupplierID); if (isDeleted) { WriteLine("Supplier Deleted"); } } } else { WriteLine($"Invalid Supplier #.\nPlease enter a number between 1 to {suppliers.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
// GET: RawMaterialOrder // URL : RawMaterialOrder/Create public async System.Threading.Tasks.Task <ActionResult> Create() { RawMaterialBL rawMaterialBL = new RawMaterialBL(); SupplierBL supplierBL = new SupplierBL(); List <RawMaterial> rawMaterials = await rawMaterialBL.GetAllRawMaterialsBL(); List <Supplier> suppliers = await supplierBL.GetAllSuppliersBL(); ViewBag.list1 = new SelectList(rawMaterials, "RawMaterialID", "RawMaterialName"); ViewBag.list2 = new SelectList(suppliers, "SupplierID", "SupplierName"); //Creating and initializing viewmodel object RawMaterialOrderViewModel rawMaterialOrderViewModel = new RawMaterialOrderViewModel(); //Calling view and passing viewmodel object to view return(View(rawMaterialOrderViewModel)); }
public static async Task PlaceOrder() { try { string choice1 = "N"; List <RawMaterial> selectedRawMaterials = new List <RawMaterial>(); List <double> quantitylist = new List <double>(); RawMaterialOrder RawMaterialorder = new RawMaterialOrder(); IRawMaterialOrderBL RawMaterialorderBL = new RawMaterialOrderBL(); ISupplierBL SupplierBL = new SupplierBL(); Supplier Supplier = new Supplier(); RawMaterial RawMaterial = new RawMaterial(); RawMaterialBL rawMaterialBL = new RawMaterialBL(); IRawMaterialOrderDetailBL RawMaterialorderDetailBL = new RawMaterialOrderDetailBL(); Supplier = await SupplierBL.GetSupplierByEmailBL(CommonData.CurrentUser.Email); List <RawMaterial> RawMaterialList = new List <RawMaterial>(); RawMaterialList = await rawMaterialBL.GetAllRawMaterialsBL(); foreach (RawMaterial item in RawMaterialList) { WriteLine(item.RawMaterialName + " " + item.RawMaterialCode); } do { WriteLine("Enter the code of the RawMaterial "); string code = ReadLine(); RawMaterial rawMaterial = await rawMaterialBL.GetRawMaterialByRawMaterialCodeBL("code"); if (rawMaterial != null) { WriteLine("Enter the Quantity of the RawMaterial "); RawMaterialorder.RawMaterialTotalQuantity = double.Parse(ReadLine()); } else { WriteLine("wrong raw material code"); } // RawMaterial rawMaterial1 = await rawMaterialBL.GetRawMaterialByRawMaterialCodeBL(code); selectedRawMaterials.Add(rawMaterial); double RawMaterialorderTotalPrice = rawMaterial.RawMaterialPrice * RawMaterialorder.RawMaterialTotalQuantity; Console.WriteLine("Do you want to add more RawMaterials? Enter Y/N"); choice1 = Console.ReadLine(); } while (choice1 == "Y"); int j = 0; double totalorderprice = 0.00; double totalquantity = 0.0; foreach (RawMaterial item in selectedRawMaterials) { totalorderprice += item.RawMaterialPrice * quantitylist[j]; totalquantity += quantitylist[j]; j++; } Console.WriteLine("Total price of the order" + totalorderprice); Console.WriteLine("do you want to place the order? \n Enter 1 for yes 0 for no "); int m = int.Parse(Console.ReadLine()); Guid orderID; if (m == 1) { SupplierBL supplierBL = new SupplierBL(); List <Supplier> list1 = await supplierBL.GetAllSuppliersBL(); RawMaterialorder.RawMaterialTotalPrice = totalorderprice; RawMaterialorder.SupplierID = RawMaterialorder.RawMaterialTotalQuantity = totalquantity; orderID = await RawMaterialorderBL.AddRawMaterialOrderBL(RawMaterialorder); for (int i = 0; i < selectedRawMaterials.Count; i++) { RawMaterialOrderDetail RawMaterialorderdetail = new RawMaterialOrderDetail(); RawMaterialorderdetail.RawMaterialOrderID = orderID; RawMaterial = await rawMaterialBL.GetRawMaterialByRawMaterialCodeBL(selectedRawMaterials[i].RawMaterialCode); RawMaterialorderdetail.RawMaterialID = RawMaterial.RawMaterialID; RawMaterialorderdetail.RawMaterialQuantity = quantitylist[i]; RawMaterialorderdetail.RawMaterialUnitPrice = RawMaterial.RawMaterialPrice; RawMaterialorderdetail.RawMaterialTotalPrice = quantitylist[i] * RawMaterial.RawMaterialPrice; await RawMaterialorderDetailBL.AddRawMaterialOrderDetailBL(RawMaterialorderdetail); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }