public Message actionCreateCollectionPoint(CollectionPoint objIn)
 {
     try
     {
         data.CollectionPoints.AddObject(objIn);
         return this.getNewDefaultMessageForDBOperations(data.SaveChanges() == 1);
     }
     catch (Exception e)
     {
         return this.getNewDefaultMessageForException(e);
     }
 }
 public Message actionUpdateCollectionPoint(CollectionPoint objIn)
 {
     try
     {
         objIn.EntityKey = data.CollectionPoints.Where(o => o.id == objIn.id).Single().EntityKey;
         data.CollectionPoints.ApplyCurrentValues(objIn);
         return this.getNewDefaultMessageForDBOperations(data.SaveChanges() == 1);
     }
     catch (Exception e)
     {
         return this.getNewDefaultMessageForException(e);
     }
 }
Ejemplo n.º 3
0
        public DBSeeder(InventoryManagementSystemContext db,
                        IWebHostEnvironment environment,
                        ProductService pService,
                        DepartmentService dService,
                        ProductCategoryService pcService,
                        DisbursementFormService dfService,
                        StationeryRetrievalFormService srfService,
                        EmployeeTypeService etService,
                        EmployeeService empService,
                        RequisitionService rfService,
                        DelegationService delService,
                        SupplierService supService,
                        SupplierProductService spService,
                        InventoryTransactionService itService)
        {
            _hostingEnvironment = environment;



            var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");

            string filePath6   = Path.Combine(uploads, "ProductCategory.csv");
            string jsonString6 = ReadCSVFileUtil.ReadCSVFile(filePath6);
            List <CSVProductCategory> productCategories = (List <CSVProductCategory>)JsonConvert.DeserializeObject(jsonString6, (typeof(List <CSVProductCategory>)));

            pcService.SaveProductCategoryFromCSV(productCategories);

            string             filePath7   = Path.Combine(uploads, "Supplier.csv");
            string             jsonString7 = ReadCSVFileUtil.ReadCSVFile(filePath7);
            List <CSVSupplier> suppliers   = (List <CSVSupplier>)JsonConvert.DeserializeObject(jsonString7, (typeof(List <CSVSupplier>)));

            supService.SaveSuppliersFromCSV(suppliers);

            string filePath3   = Path.Combine(uploads, "EmployeeType.csv");
            string jsonString3 = ReadCSVFileUtil.ReadCSVFile(filePath3);
            List <CSVEmployeeType> employeeTypes = (List <CSVEmployeeType>)JsonConvert.DeserializeObject(jsonString3, (typeof(List <CSVEmployeeType>)));

            etService.SaveEmployeeTypesFromCSV(employeeTypes);

            ProductCategory pc1  = pcService.findProductCategory("Clip");
            ProductCategory pc2  = pcService.findProductCategory("Envelope");
            ProductCategory pc3  = pcService.findProductCategory("Eraser");
            ProductCategory pc4  = pcService.findProductCategory("Exercise");
            ProductCategory pc5  = pcService.findProductCategory("File");
            ProductCategory pc6  = pcService.findProductCategory("Pen");
            ProductCategory pc7  = pcService.findProductCategory("Puncher");
            ProductCategory pc8  = pcService.findProductCategory("Pad");
            ProductCategory pc9  = pcService.findProductCategory("Paper");
            ProductCategory pc10 = pcService.findProductCategory("Ruler");
            ProductCategory pc11 = pcService.findProductCategory("Scissors");
            ProductCategory pc12 = pcService.findProductCategory("Tape");
            ProductCategory pc13 = pcService.findProductCategory("Sharpener");
            ProductCategory pc14 = pcService.findProductCategory("Shorthand");
            ProductCategory pc15 = pcService.findProductCategory("Stapler");
            ProductCategory pc16 = pcService.findProductCategory("Tacks");
            ProductCategory pc17 = pcService.findProductCategory("Tparency");
            ProductCategory pc18 = pcService.findProductCategory("Tray");

            string            filePath1  = Path.Combine(uploads, "Product.csv");
            string            jsonString = ReadCSVFileUtil.ReadCSVFile(filePath1);
            List <CSVProduct> products   = (List <CSVProduct>)JsonConvert.DeserializeObject(jsonString, (typeof(List <CSVProduct>)));

            pService.SaveProductsFromCSV(products);



            string filePath9   = Path.Combine(uploads, "SupplierProduct.csv");
            string jsonString9 = ReadCSVFileUtil.ReadCSVFile(filePath9);
            List <CSVSupplierProduct> supplierProducts = (List <CSVSupplierProduct>)JsonConvert.DeserializeObject(jsonString9, (typeof(List <CSVSupplierProduct>)));

            spService.SaveSupplierProductsFromCSV(supplierProducts);

            //save the images under images folder to database
            var           imagefolder = Path.Combine(_hostingEnvironment.WebRootPath, "images");
            DirectoryInfo Folder      = new DirectoryInfo(imagefolder);

            FileInfo[]    Images     = Folder.GetFiles();
            List <String> imagesList = new List <String>();

            foreach (var image in Images)
            {
                imagesList.Add(String.Format(@"{0}", image.Name));
            }
            pService.SaveProductImages(imagesList);


            EmployeeType empType1 = etService.FindEmployeeTypeByEmployeeTypeName("Store Clerk");
            EmployeeType empType2 = etService.FindEmployeeTypeByEmployeeTypeName("Store Supervisor");
            EmployeeType empType3 = etService.FindEmployeeTypeByEmployeeTypeName("Store Manager");
            EmployeeType empType4 = etService.FindEmployeeTypeByEmployeeTypeName("Employee");
            EmployeeType empType5 = etService.FindEmployeeTypeByEmployeeTypeName("Department Head");
            EmployeeType empType6 = etService.FindEmployeeTypeByEmployeeTypeName("Department Representative");
            EmployeeType empType7 = etService.FindEmployeeTypeByEmployeeTypeName("Warehouse Packer");
            EmployeeType empType8 = etService.FindEmployeeTypeByEmployeeTypeName("Temporary Department Head");


            CollectionPoint cp1 = new CollectionPoint()
            {
                CollectionName = "Stationery Store - Administration Building"
            };
            CollectionPoint cp2 = new CollectionPoint()
            {
                CollectionName = "Management School"
            };
            CollectionPoint cp3 = new CollectionPoint()
            {
                CollectionName = "Medical School"
            };
            CollectionPoint cp4 = new CollectionPoint()
            {
                CollectionName = "Engineering School"
            };
            CollectionPoint cp5 = new CollectionPoint()
            {
                CollectionName = "Science School"
            };
            CollectionPoint cp6 = new CollectionPoint()
            {
                CollectionName = "University Hospital"
            };

            db.Add(cp1);
            db.Add(cp2);
            db.Add(cp3);
            db.Add(cp4);
            db.Add(cp5);
            db.Add(cp6);

            Department dept1 = new Department()
            {
                DepartmentName = "Store", DeptCode = "STOR", CollectionPoint = cp1, PhoneNumber = "12345678"
            };
            Department dept2 = new Department()
            {
                DepartmentName = "English Department", DeptCode = "ENDP", CollectionPoint = cp2, PhoneNumber = "98765432"
            };
            Department dept3 = new Department()
            {
                DepartmentName = "Chinese Department", DeptCode = "CHSL", CollectionPoint = cp2, PhoneNumber = "87654321"
            };
            Department dept4 = new Department()
            {
                DepartmentName = "Engineering Department", DeptCode = "ENGD", CollectionPoint = cp1, PhoneNumber = "76543219"
            };
            Department dept5 = new Department()
            {
                DepartmentName = "Arts Department", DeptCode = "ARTD", CollectionPoint = cp3, PhoneNumber = "53046012"
            };
            Department dept6 = new Department()
            {
                DepartmentName = "Business Department", DeptCode = "BIZD", CollectionPoint = cp4, PhoneNumber = "15397864"
            };
            Department dept7 = new Department()
            {
                DepartmentName = "Science Department", DeptCode = "SCID", CollectionPoint = cp5, PhoneNumber = "68425397"
            };
            Department dept8 = new Department()
            {
                DepartmentName = "Management Department", DeptCode = "MNGD", CollectionPoint = cp6, PhoneNumber = "86957412"
            };
            Department dept9 = new Department()
            {
                DepartmentName = "HQ Department", DeptCode = "HQDP", CollectionPoint = cp3, PhoneNumber = "32540325"
            };
            Department dept10 = new Department()
            {
                DepartmentName = "Music Department", DeptCode = "MSDP", CollectionPoint = cp4, PhoneNumber = "78954120"
            };

            db.Add(dept1);
            db.Add(dept2);
            db.Add(dept3);
            db.Add(dept4);
            db.Add(dept5);
            db.Add(dept6);
            db.Add(dept7);
            db.Add(dept8);
            db.Add(dept9);
            db.Add(dept10);
            db.SaveChanges();

            string             filePath4   = Path.Combine(uploads, "Employee.csv");
            string             jsonString4 = ReadCSVFileUtil.ReadCSVFile(filePath4);
            List <CSVEmployee> employees   = (List <CSVEmployee>)JsonConvert.DeserializeObject(jsonString4, (typeof(List <CSVEmployee>)));

            empService.SaveEmployeesFromCSV(employees);
            empService.SaveEmployeesSupervisedByFromCSV(employees);

            Employee emp1  = empService.GetEmployee("thinn");
            Employee emp2  = empService.GetEmployee("arjun");
            Employee emp3  = empService.GetEmployee("rohan");
            Employee emp4  = empService.GetEmployee("darell");
            Employee emp5  = empService.GetEmployee("yamone");
            Employee emp6  = empService.GetEmployee("sheryl");
            Employee emp7  = empService.GetEmployee("xinqi");
            Employee emp8  = empService.GetEmployee("yanbin");
            Employee emp9  = empService.GetEmployee("darellmgr2");
            Employee emp10 = empService.GetEmployee("thinn2");

            Product pr1 = pService.FindProductById(1);
            Product pr2 = pService.FindProductById(2);
            Product pr3 = pService.FindProductById(3);
            Product pr4 = pService.FindProductById(4);
            Product pr5 = pService.FindProductById(5);
            Product pr6 = pService.FindProductById(6);


            DateTime dd1  = new DateTime(2020, 8, 13, 8, 30, 20);
            DateTime dd2  = new DateTime(2020, 8, 14, 8, 30, 20);
            DateTime dd3  = new DateTime(2020, 8, 12, 8, 40, 20);
            DateTime dd4  = new DateTime(2020, 8, 10, 8, 30, 20);
            DateTime dd13 = new DateTime(2020, 8, 15, 8, 30, 20);



            RequisitionForm rq1 = new RequisitionForm()
            {
                RFCode = "RF/" + emp1.Department.DeptCode + "/" + dd1.ToString("ddMMyy") + "/1", Employee = emp1, RFStatus = Enums.RFStatus.Approved, RFDate = dd1, RFApprovalDate = dd1, RFComments = "", RFApprovalBy = emp9
            };
            RequisitionForm rq2 = new RequisitionForm()
            {
                RFCode = "RF/" + emp1.Department.DeptCode + "/" + dd2.ToString("ddMMyy") + "/1", Employee = emp1, RFStatus = Enums.RFStatus.Ongoing, RFDate = dd2, RFApprovalDate = dd1, RFComments = "", RFApprovalBy = emp9
            };
            //RequisitionForm rq3 = new RequisitionForm() { RFCode = "RF/" + emp2.Department.DeptCode + "/" + dd3.ToString("ddMMyy") + "/1", Employee = emp2, RFStatus = Enums.RFStatus.Approved, RFDate = dd3, RFApprovalDate = dd1, RFComments = "", RFApprovalBy = emp9 };
            RequisitionForm rq4 = new RequisitionForm()
            {
                RFCode = "RF/" + emp1.Department.DeptCode + "/" + dd1.ToString("ddMMyy") + "/2", Employee = emp1, RFStatus = Enums.RFStatus.Submitted, RFDate = dd1
            };
            RequisitionForm rq5 = new RequisitionForm()
            {
                RFCode = "RF/" + emp1.Department.DeptCode + "/" + dd2.ToString("ddMMyy") + "/2", Employee = emp1, RFStatus = Enums.RFStatus.Submitted, RFDate = dd2
            };

            db.Add(rq1);
            db.Add(rq2);
            //db.Add(rq3);
            db.Add(rq4);
            db.Add(rq5);



            RequisitionFormsProduct rq1_p1 = new RequisitionFormsProduct()
            {
                RequisitionForm = rq1, Product = pr1, ProductRequested = 10, ProductApproved = 10
            };
            RequisitionFormsProduct rq1_p2 = new RequisitionFormsProduct()
            {
                RequisitionForm = rq1, Product = pr2, ProductRequested = 10, ProductApproved = 10
            };
            RequisitionFormsProduct rq2_p1 = new RequisitionFormsProduct()
            {
                RequisitionForm = rq2, Product = pr1, ProductRequested = 5, ProductApproved = 5
            };
            RequisitionFormsProduct rq2_p2 = new RequisitionFormsProduct()
            {
                RequisitionForm = rq2, Product = pr2, ProductRequested = 3, ProductApproved = 2
            };
            //RequisitionFormsProduct rq3_p1 = new RequisitionFormsProduct() { RequisitionForm = rq3, Product = pr1, ProductRequested = 10, ProductApproved = 5 };
            //RequisitionFormsProduct rq3_p2 = new RequisitionFormsProduct() { RequisitionForm = rq3, Product = pr2, ProductRequested = 10, ProductApproved = 7 };
            RequisitionFormsProduct rq4_p1 = new RequisitionFormsProduct()
            {
                RequisitionForm = rq1, Product = pr4, ProductRequested = 10, ProductApproved = 10
            };
            RequisitionFormsProduct rq5_p1 = new RequisitionFormsProduct()
            {
                RequisitionForm = rq1, Product = pr5, ProductRequested = 10, ProductApproved = 1
            };



            db.Add(rq1);
            db.Add(rq2);
            //db.Add(rq3);

            db.Add(rq1_p1);
            db.Add(rq1_p2);
            db.Add(rq2_p1);
            db.Add(rq2_p2);
            //db.Add(rq3_p1);
            //db.Add(rq3_p2);
            db.Add(rq4_p1);
            db.Add(rq5_p1);

            //db.SaveChanges();

            /*For Testing*/
            StationeryRetrieval sr1 = new StationeryRetrieval()
            {
                SRCode = "SR/" + dd1.ToString("ddMMyy") + "/1", SRStatus = Enums.SRStatus.PendingAssignment, SRComments = "Pending Assignment", SRDate = dd1, StoreClerk = emp1, WarehousePacker = emp7, SRRetrievalDate = dd2
            };
            StationeryRetrieval sr2 = new StationeryRetrieval()
            {
                SRCode = "SR/" + dd1.ToString("ddMMyy") + "/2", SRStatus = Enums.SRStatus.Assigned, SRComments = "Assigned", SRDate = dd1, StoreClerk = emp1, WarehousePacker = emp7, SRRetrievalDate = dd2, SRAssignedDate = dd13
            };

            //StationeryRetrieval sr3 = new StationeryRetrieval() { SRCode = "SR/" + dd1.ToString("ddMMyy") + "/3", SRStatus = Enums.SRStatus.Open, SRComments = "Open", SRDate = dd1, StoreClerk = emp1 };
            db.Add(sr1);
            db.Add(sr2);
            //db.Add(sr3);
            db.SaveChanges();

            StationeryRetrievalProduct srpr1 = new StationeryRetrievalProduct()
            {
                Product = pr1, ProductRequestedTotal = 5, StationeryRetrieval = sr1, ProductReceivedTotal = 4
            };
            StationeryRetrievalProduct srpr2 = new StationeryRetrievalProduct()
            {
                Product = pr2, ProductRequestedTotal = 10, StationeryRetrieval = sr1, ProductReceivedTotal = 10
            };
            StationeryRetrievalProduct srpr3 = new StationeryRetrievalProduct()
            {
                Product = pr1, ProductRequestedTotal = 5, StationeryRetrieval = sr2
            };
            StationeryRetrievalProduct srpr4 = new StationeryRetrievalProduct()
            {
                Product = pr2, ProductRequestedTotal = 10, StationeryRetrieval = sr2
            };

            db.Add(srpr1);
            db.Add(srpr2);
            db.Add(srpr3);
            db.Add(srpr4);
            //db.Add(srpr5);
            //db.Add(srpr6);
            db.SaveChanges();

            StationeryRetrievalRequisitionForm sr1_rf_1 = new StationeryRetrievalRequisitionForm()
            {
                RequisitionForm = rq1, SRRFStatus = Enums.SRRFStatus.PendingAssignment, StationeryRetrieval = sr1
            };
            StationeryRetrievalRequisitionForm sr1_rf_2 = new StationeryRetrievalRequisitionForm()
            {
                RequisitionForm = rq2, SRRFStatus = Enums.SRRFStatus.PendingAssignment, StationeryRetrieval = sr1
            };

            //StationeryRetrievalRequisitionForm sr2_rf_3 = new StationeryRetrievalRequisitionForm() { RequisitionForm = rq3, SRRFStatus = Enums.SRRFStatus.PendingAssignment, StationeryRetrieval = sr2 };
            db.Add(sr1_rf_1);
            db.Add(sr1_rf_2);
            //db.Add(sr2_rf_3);
            db.SaveChanges();

            StationeryRetrievalRequisitionFormProduct sr1_rf1_pr_1 = new StationeryRetrievalRequisitionFormProduct()
            {
                SR = sr1, RFP = rq1_p1
            };
            StationeryRetrievalRequisitionFormProduct sr1_rf1_pr_2 = new StationeryRetrievalRequisitionFormProduct()
            {
                SR = sr1, RFP = rq1_p2
            };
            StationeryRetrievalRequisitionFormProduct sr1_rf2_pr_1 = new StationeryRetrievalRequisitionFormProduct()
            {
                SR = sr1, RFP = rq2_p1
            };
            StationeryRetrievalRequisitionFormProduct sr1_rf2_pr_2 = new StationeryRetrievalRequisitionFormProduct()
            {
                SR = sr1, RFP = rq2_p2
            };

            //StationeryRetrievalRequisitionFormProduct sr1_rf3_pr_1 = new StationeryRetrievalRequisitionFormProduct() { SR = sr1, RFP = rq3_p2 };

            db.Add(sr1_rf1_pr_1);
            db.Add(sr1_rf1_pr_2);
            db.Add(sr1_rf2_pr_1);
            db.Add(sr1_rf2_pr_2);

            db.SaveChanges();
            /*End For Testing*/



            //Testing for RequisitionFormDisplay

            DateTime dd5 = new DateTime(2020, 8, 10, 8, 30, 20);
            DateTime dd6 = new DateTime(2020, 8, 11, 8, 30, 20);
            DateTime dd7 = new DateTime(2020, 8, 10, 8, 30, 20);

            string filePath5              = Path.Combine(uploads, "RequisitionForm.csv");
            string jsonString5            = ReadCSVFileUtil.ReadCSVFile(filePath5);
            List <CSVRequisitionForm> rfs = (List <CSVRequisitionForm>)JsonConvert.DeserializeObject(jsonString5, (typeof(List <CSVRequisitionForm>)));

            rfService.SaveRFFromCSV(rfs);

            RequisitionForm rq6 = new RequisitionForm()
            {
                RFCode = "RF/" + emp1.Department.DeptCode + "/" + dd5.ToString("ddMMyy") + "/1", Employee = emp1, RFStatus = Enums.RFStatus.NotCompleted, RFDate = dd5, RFApprovalDate = dd6, RFApprovalBy = emp9
            };
            RequisitionFormsProduct rfp1 = new RequisitionFormsProduct()
            {
                Product = pr1, ProductRequested = 10, RequisitionForm = rq6, ProductCollectedTotal = 9, ProductApproved = 10
            };
            RequisitionFormsProduct rfp2 = new RequisitionFormsProduct()
            {
                Product = pr2, ProductRequested = 20, RequisitionForm = rq6, ProductCollectedTotal = 7, ProductApproved = 10
            };

            db.Add(rq6);
            db.Add(rfp1);
            db.Add(rfp2);

            DisbursementForm df1 = new DisbursementForm()
            {
                CollectionPoint = cp1, DFCode = "DF/" + emp2.Department.DeptCode + "/" + dd1.ToString("ddMMyy") + "/1", DeptRep = emp2, StoreClerk = emp4, DFDeliveryDate = dd2, DFStatus = Enums.DFStatus.Created, DFDate = dd1
            };
            DisbursementForm df2 = new DisbursementForm()
            {
                CollectionPoint = cp2, DFCode = "DF/" + emp2.Department.DeptCode + "/" + dd1.ToString("ddMMyy") + "/2", DeptRep = emp2, StoreClerk = emp4, DFDeliveryDate = dd2, DFStatus = Enums.DFStatus.Completed, DFDate = dd1
            };
            DisbursementFormRequisitionForm dfrf1 = new DisbursementFormRequisitionForm()
            {
                DisbursementForm = df1, DFRFStatus = Enums.DFRFStatus.Assigned, RequisitionForm = rq1
            };
            DisbursementFormRequisitionForm dfrf2 = new DisbursementFormRequisitionForm()
            {
                DisbursementForm = df1, DFRFStatus = Enums.DFRFStatus.Assigned, RequisitionForm = rq2
            };
            DisbursementFormRequisitionFormProduct dfrfp1 = new DisbursementFormRequisitionFormProduct()
            {
                DisbursementForm = df1, RequisitionFormsProduct = rfp1, ProductCollected = 9
            };
            DisbursementFormRequisitionFormProduct dfrfp2 = new DisbursementFormRequisitionFormProduct()
            {
                DisbursementForm = df1, RequisitionFormsProduct = rfp2, ProductCollected = 7
            };

            db.Add(df1);
            db.Add(df2);
            db.Add(dfrf1);
            db.Add(dfrf2);
            db.Add(dfrfp1);
            db.Add(dfrfp2);
            db.SaveChanges();

            //DisbursementFormRequisitionForm dfrf3 = new DisbursementFormRequisitionForm() { DFRFStatus = Enums.DFRFStatus.PendingDelivery, DisbursementForm = df1, RequisitionForm = rq1 };
            //DisbursementFormRequisitionForm dfrf4 = new DisbursementFormRequisitionForm() { DFRFStatus = Enums.DFRFStatus.PendingDelivery, DisbursementForm = df1, RequisitionForm = rq2 };
            //db.Add(dfrf3);
            //db.Add(dfrf4);
            db.SaveChanges();
            DisbursementFormProduct dfp1 = new DisbursementFormProduct()
            {
                DisbursementForm = df1, Product = pr1, ProductToDeliverTotal = 10
            };
            DisbursementFormProduct dfp2 = new DisbursementFormProduct()
            {
                DisbursementForm = df1, Product = pr2, ProductToDeliverTotal = 40
            };

            db.Add(dfp1);
            db.Add(dfp2);
            db.SaveChanges();


            Supplier sup1  = db.Suppliers.Find(1);
            Supplier sup2  = db.Suppliers.Find(2);
            Supplier sup3  = db.Suppliers.Find(3);
            Supplier sup4  = db.Suppliers.Find(4);
            Supplier sup5  = db.Suppliers.Find(5);
            Supplier sup6  = db.Suppliers.Find(6);
            Supplier sup7  = db.Suppliers.Find(7);
            Supplier sup8  = db.Suppliers.Find(8);
            Supplier sup9  = db.Suppliers.Find(9);
            Supplier sup10 = db.Suppliers.Find(10);
            Supplier sup11 = db.Suppliers.Find(11);
            Supplier sup12 = db.Suppliers.Find(12);
            Supplier sup13 = db.Suppliers.Find(13);
            Supplier sup14 = db.Suppliers.Find(14);
            Supplier sup15 = db.Suppliers.Find(15);
            Supplier sup16 = db.Suppliers.Find(16);
            Supplier sup17 = db.Suppliers.Find(17);
            Supplier sup18 = db.Suppliers.Find(18);
            Supplier sup19 = db.Suppliers.Find(19);
            Supplier sup20 = db.Suppliers.Find(20);

            //db.Add(sup1);
            //db.Add(sup2);
            //db.Add(sup3);
            //db.Add(sup4);
            db.SaveChanges();

            DateTime dd8  = new DateTime(2020, 8, 10, 8, 30, 20);
            DateTime dd9  = new DateTime(2020, 8, 22, 8, 30, 20);
            DateTime dd10 = new DateTime(2020, 7, 10, 8, 40, 20);
            DateTime dd11 = new DateTime(2020, 9, 12, 8, 30, 20);
            DateTime dd12 = new DateTime(2020, 9, 13, 9, 30, 20);

            SupplierProduct sp1 = db.SupplierProducts.Find(1);
            SupplierProduct sp2 = db.SupplierProducts.Find(6);
            SupplierProduct sp3 = db.SupplierProducts.Find(3);
            SupplierProduct sp4 = db.SupplierProducts.Find(4);

            //db.Add(sp1);
            //db.Add(sp2);
            //db.Add(sp3);
            //db.Add(sp4);
            db.SaveChanges();

            PurchaseOrder po1 = new PurchaseOrder()
            {
                supplier = sup1, DeliverTo = "Logic University - Store", expectedDeliveryDate = dd9, IssuedBy = emp7, POStatus = Enums.POStatus.Issued, POComments = "Order affected by COVID", POCode = "PO/" + dd8.ToString("ddMMyy") + "/1", POIssueDate = dd8
            };
            PurchaseOrder po2 = new PurchaseOrder()
            {
                supplier = sup2, DeliverTo = "Logic University - Store", expectedDeliveryDate = dd11, IssuedBy = emp7, POStatus = Enums.POStatus.Completed, POComments = "Some Items may be out of stock", POCode = "PO/" + dd10.ToString("ddMMyy") + "/1", POIssueDate = dd10
            };
            PurchaseOrder po3 = new PurchaseOrder()
            {
                supplier = sup2, DeliverTo = "Logic University - Store", expectedDeliveryDate = dd12, IssuedBy = emp7, POStatus = Enums.POStatus.NotCompleted, POComments = "Urgent", POCode = "PO/" + dd10.ToString("ddMMyy") + "/2", POIssueDate = dd10
            };

            db.Add(po1);
            db.Add(po2);
            db.Add(po3);


            PurchaseOrderSupplierProduct posr1 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp1, POQuantityRequested = 10, POUnitPrice = sp1.ProductPrice, PurchaseOrder = po1
            };
            PurchaseOrderSupplierProduct posr2 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp2, POQuantityRequested = 15, POUnitPrice = sp2.ProductPrice, PurchaseOrder = po1
            };
            PurchaseOrderSupplierProduct posr3 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp3, POQuantityRequested = 5, POUnitPrice = sp3.ProductPrice, PurchaseOrder = po1
            };

            PurchaseOrderSupplierProduct posr4 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp1, POQuantityRequested = 3, POUnitPrice = sp1.ProductPrice, PurchaseOrder = po2
            };
            PurchaseOrderSupplierProduct posr5 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp2, POQuantityRequested = 5, POUnitPrice = sp2.ProductPrice, PurchaseOrder = po2
            };

            PurchaseOrderSupplierProduct posr6 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp3, POQuantityRequested = 3, POUnitPrice = sp3.ProductPrice, PurchaseOrder = po3
            };
            PurchaseOrderSupplierProduct posr7 = new PurchaseOrderSupplierProduct()
            {
                SupplierProduct = sp4, POQuantityRequested = 5, POUnitPrice = sp4.ProductPrice, PurchaseOrder = po3
            };

            db.Add(posr1);
            db.Add(posr2);
            db.Add(posr3);
            db.Add(posr4);
            db.SaveChanges();
            //--------------------------

            DeliveryOrder do2 = new DeliveryOrder()
            {
                DeliveryOrderNo = "D0121567", DOReceivedDate = dd11, PurchaseOrder = po2, Supplier = sup1, DOCode = "DO/" + dd11.ToString("ddMMyy") + "/1", ReceivedBy = emp7
            };
            DeliveryOrder do3 = new DeliveryOrder()
            {
                DeliveryOrderNo = "D011267", DOReceivedDate = dd12, PurchaseOrder = po3, Supplier = sup2, DOCode = "DO/" + dd12.ToString("ddMMyy") + "/1", ReceivedBy = emp7
            };

            db.Add(do2);
            db.Add(do3);
            db.SaveChanges();

            DeliveryOrderSupplierProduct dosr4 = new DeliveryOrderSupplierProduct()
            {
                PurchaseOrderSupplierProduct = posr4, DOQuantityReceived = 3, DeliveryOrder = do2
            };
            DeliveryOrderSupplierProduct dosr5 = new DeliveryOrderSupplierProduct()
            {
                PurchaseOrderSupplierProduct = posr5, DOQuantityReceived = 5, DeliveryOrder = do2
            };

            DeliveryOrderSupplierProduct dosr6 = new DeliveryOrderSupplierProduct()
            {
                PurchaseOrderSupplierProduct = posr6, DOQuantityReceived = 3, DeliveryOrder = do3
            };
            DeliveryOrderSupplierProduct dosr7 = new DeliveryOrderSupplierProduct()
            {
                PurchaseOrderSupplierProduct = posr7, DOQuantityReceived = 3, DeliveryOrder = do3
            };

            db.Add(dosr4);
            db.Add(dosr5);
            db.Add(dosr6);
            db.Add(dosr7);

            DateTime dd19 = new DateTime(2020, 8, 15, 0, 0, 0);
            DateTime dd20 = new DateTime(2020, 9, 15, 0, 0, 0);
            DateTime dd21 = new DateTime(2020, 7, 15, 10, 10, 0);

            DateTime dd22 = new DateTime(2020, 10, 15, 0, 0, 0);
            DateTime dd23 = new DateTime(2020, 11, 15, 0, 0, 0);


            DelegationForm delForm1 = new DelegationForm()
            {
                startDate       = dd19,
                endDate         = dd20,
                delegateComment = "Hello There",
                Delegatee       = emp10,
                DelegatedType   = empType8,
                DepartmentHead  = emp9,
                DLAssignedDate  = dd21,
                DLStatus        = Enums.DLStatus.Ongoing
            };

            DelegationForm delForm2 = new DelegationForm()
            {
                startDate       = dd22,
                endDate         = dd23,
                delegateComment = "Hello There",
                Delegatee       = emp10,
                DelegatedType   = empType8,
                DepartmentHead  = emp9,
                DLAssignedDate  = dd21,
                DLStatus        = Enums.DLStatus.Assigned
            };

            //DelegationForm delForm3 = new DelegationForm()
            //{
            //    startDate = dd22,
            //    endDate = dd23,
            //    delegateComment = "Hello There",
            //    Delegatee = emp10,
            //    DelegatedType = empType6,
            //    DepartmentHead = emp9,
            //    DLAssignedDate = dd21,
            //    DLStatus = Enums.DLStatus.Assigned
            //};

            db.Add(delForm1);
            db.Add(delForm2);

            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public DbSeeder(StationeryContext dbcontext)
        {
            using (MD5 md5Hash = MD5.Create())
            {
                string          time1 = "9:30am";
                string          time2 = "11:00am";
                CollectionPoint cp1   = new CollectionPoint();
                cp1.Id       = Guid.NewGuid().ToString();
                cp1.Location = "Stationery Store - Administration Building";
                cp1.Time     = time1;
                dbcontext.Add(cp1);

                CollectionPoint cp2 = new CollectionPoint();
                cp2.Id       = Guid.NewGuid().ToString();
                cp2.Location = "Management School";
                cp2.Time     = time2;
                dbcontext.Add(cp2);

                CollectionPoint cp3 = new CollectionPoint();
                cp3.Id       = Guid.NewGuid().ToString();
                cp3.Location = "Medical School";
                cp3.Time     = time1;
                dbcontext.Add(cp3);

                CollectionPoint cp4 = new CollectionPoint();
                cp4.Id       = Guid.NewGuid().ToString();
                cp4.Location = "Engineering School";
                cp4.Time     = time1;
                dbcontext.Add(cp4);

                CollectionPoint cp5 = new CollectionPoint();
                cp5.Id       = Guid.NewGuid().ToString();
                cp5.Location = "Science School";
                cp5.Time     = time1;
                dbcontext.Add(cp5);

                CollectionPoint cp6 = new CollectionPoint();
                cp6.Id       = Guid.NewGuid().ToString();
                cp6.Location = "University Hospital";
                cp6.Time     = time2;
                dbcontext.Add(cp6);


                ItemCategory category1 = new ItemCategory();
                category1.Id   = Guid.NewGuid().ToString();
                category1.name = "Clip";
                dbcontext.Add(category1);

                ItemCategory category2 = new ItemCategory();
                category2.Id   = Guid.NewGuid().ToString();
                category2.name = "Envelope";
                dbcontext.Add(category2);

                ItemCategory category3 = new ItemCategory();
                category3.Id   = Guid.NewGuid().ToString();
                category3.name = "Eraser";
                dbcontext.Add(category3);

                ItemCategory category4 = new ItemCategory();
                category4.Id   = Guid.NewGuid().ToString();
                category4.name = "Exercise";
                dbcontext.Add(category4);

                ItemCategory category5 = new ItemCategory();
                category5.Id   = Guid.NewGuid().ToString();
                category5.name = "File";
                dbcontext.Add(category5);

                ItemCategory category6 = new ItemCategory();
                category6.Id   = Guid.NewGuid().ToString();
                category6.name = "Pen";
                dbcontext.Add(category6);

                ItemCategory category7 = new ItemCategory();
                category7.Id   = Guid.NewGuid().ToString();
                category7.name = "Puncher";
                dbcontext.Add(category7);

                ItemCategory category8 = new ItemCategory();
                category8.Id   = Guid.NewGuid().ToString();
                category8.name = "Pad";
                dbcontext.Add(category8);

                ItemCategory category9 = new ItemCategory();
                category9.Id   = Guid.NewGuid().ToString();
                category9.name = "Paper";
                dbcontext.Add(category9);

                ItemCategory category10 = new ItemCategory();
                category10.Id   = Guid.NewGuid().ToString();
                category10.name = "Ruler";
                dbcontext.Add(category10);

                Inventory item1 = new Inventory();
                item1.Id              = Guid.NewGuid().ToString();
                item1.ItemCategoryId  = category1.Id;
                item1.itemCode        = "C001";
                item1.description     = "Clips Double 1";
                item1.stock           = 100;
                item1.measurementUnit = "Dozen";
                item1.location        = "bin01";
                item1.reorderLevel    = 50;
                item1.reorderQty      = 30;
                item1.price           = 1;
                dbcontext.Add(item1);

                Inventory item2 = new Inventory();
                item2.Id              = Guid.NewGuid().ToString();
                item2.ItemCategoryId  = category1.Id;
                item2.itemCode        = "C002";
                item2.description     = "Clips Double 2";
                item2.stock           = 100;
                item2.measurementUnit = "Dozen";
                item2.location        = "bin01";
                item2.reorderLevel    = 50;
                item2.reorderQty      = 30;
                item2.price           = 10;
                dbcontext.Add(item2);

                Inventory item3 = new Inventory();
                item3.Id              = Guid.NewGuid().ToString();
                item3.ItemCategoryId  = category1.Id;
                item3.itemCode        = "C003";
                item3.description     = "Clips Double 3/4";
                item3.stock           = 100;
                item3.measurementUnit = "Dozen";
                item3.location        = "bin01";
                item3.reorderLevel    = 50;
                item3.reorderQty      = 30;
                item3.price           = 2;
                dbcontext.Add(item3);

                Inventory item4 = new Inventory();
                item4.Id              = Guid.NewGuid().ToString();
                item4.ItemCategoryId  = category1.Id;
                item4.itemCode        = "C004";
                item4.description     = "Clips Paper Large";
                item4.stock           = 100;
                item4.measurementUnit = "Box";
                item4.location        = "bin01";
                item4.reorderLevel    = 50;
                item4.reorderQty      = 30;
                item4.price           = 3;
                dbcontext.Add(item4);

                Inventory item5 = new Inventory();
                item5.Id              = Guid.NewGuid().ToString();
                item5.ItemCategoryId  = category1.Id;
                item5.itemCode        = "C005";
                item5.description     = "Clips Paper Medium";
                item5.stock           = 100;
                item5.measurementUnit = "Box";
                item5.location        = "bin01";
                item5.reorderLevel    = 50;
                item5.reorderQty      = 30;
                item5.price           = 1.5;
                dbcontext.Add(item5);

                Inventory item6 = new Inventory();
                item6.Id              = Guid.NewGuid().ToString();
                item6.ItemCategoryId  = category1.Id;
                item6.itemCode        = "C006";
                item6.description     = "Clips Paper Small";
                item6.stock           = 100;
                item6.measurementUnit = "Box";
                item6.location        = "bin01";
                item6.reorderLevel    = 50;
                item6.reorderQty      = 30;
                item6.price           = 0.5;
                dbcontext.Add(item6);

                Inventory item7 = new Inventory();
                item7.Id              = Guid.NewGuid().ToString();
                item7.ItemCategoryId  = category2.Id;
                item7.itemCode        = "E001";
                item7.description     = "Envelope Brown(3x6)";
                item7.stock           = 1000;
                item7.measurementUnit = "Each";
                item7.location        = "bin02";
                item7.reorderLevel    = 600;
                item7.reorderQty      = 400;
                item7.price           = 0.7;
                dbcontext.Add(item7);

                Inventory item8 = new Inventory();
                item8.Id              = Guid.NewGuid().ToString();
                item8.ItemCategoryId  = category2.Id;
                item8.itemCode        = "E002";
                item8.description     = "Envelope Brown(3x6) w/Window";
                item8.stock           = 1000;
                item8.measurementUnit = "Each";
                item8.location        = "bin02";
                item8.reorderLevel    = 600;
                item8.reorderQty      = 400;
                item8.price           = 0.9;
                dbcontext.Add(item8);

                Inventory item9 = new Inventory();
                item9.Id              = Guid.NewGuid().ToString();
                item9.ItemCategoryId  = category2.Id;
                item9.itemCode        = "E003";
                item9.description     = "Envelope Brown(5x7)";
                item9.stock           = 1000;
                item9.measurementUnit = "Each";
                item9.location        = "bin02";
                item9.reorderLevel    = 600;
                item9.reorderQty      = 400;
                item9.price           = 0.8;
                dbcontext.Add(item9);

                Inventory item10 = new Inventory();
                item10.Id              = Guid.NewGuid().ToString();
                item10.ItemCategoryId  = category2.Id;
                item10.itemCode        = "E004";
                item10.description     = "Envelope Brown(5x7) w/Window";
                item10.stock           = 1000;
                item10.measurementUnit = "Each";
                item10.location        = "bin02";
                item10.reorderLevel    = 600;
                item10.reorderQty      = 400;
                item10.price           = 1.1;
                dbcontext.Add(item10);

                Supplier supplier1 = new Supplier();
                supplier1.Id           = Guid.NewGuid().ToString();
                supplier1.supplierCode = "ALPA";
                supplier1.name         = "ALPHA Office Supplies";
                supplier1.address      = "Blk 1128, Ang Mo Kio Industrial Park #02-1108 Ang Mo Kio Street 62 Singapore 622262";
                supplier1.contactNo    = 4619928;
                supplier1.faxNo        = 4612238;
                dbcontext.Add(supplier1);

                Supplier supplier2 = new Supplier();
                supplier2.Id           = Guid.NewGuid().ToString();
                supplier2.supplierCode = "CHEP";
                supplier2.name         = "Cheap Stationer";
                supplier2.address      = "Blk 34, Clementi Road #07-02 Ban Ban Soh Building Singapore 110525";
                supplier2.contactNo    = 3543234;
                supplier2.faxNo        = 4742434;
                dbcontext.Add(supplier2);

                Supplier supplier3 = new Supplier();
                supplier3.Id           = Guid.NewGuid().ToString();
                supplier3.supplierCode = "BANE";
                supplier3.name         = "BANES Shop";
                supplier3.address      = "Blk 124, Alexandra Road #03-04 Banes Building Singapore 550315";
                supplier3.contactNo    = 4781234;
                supplier3.faxNo        = 4792434;
                dbcontext.Add(supplier3);

                Inventory_Supplier inventory_Supplier1 = new Inventory_Supplier();
                inventory_Supplier1.Id = Guid.NewGuid().ToString();
                inventory_Supplier1.InventoryItemId = item1.Id;
                inventory_Supplier1.SupplierId      = supplier1.Id;
                inventory_Supplier1.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier1);

                Inventory_Supplier inventory_Supplier2 = new Inventory_Supplier();
                inventory_Supplier2.Id = Guid.NewGuid().ToString();
                inventory_Supplier2.InventoryItemId = item2.Id;
                inventory_Supplier2.SupplierId      = supplier1.Id;
                inventory_Supplier2.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier2);

                Inventory_Supplier inventory_Supplier3 = new Inventory_Supplier();
                inventory_Supplier3.Id = Guid.NewGuid().ToString();
                inventory_Supplier3.InventoryItemId = item3.Id;
                inventory_Supplier3.SupplierId      = supplier1.Id;
                inventory_Supplier3.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier3);

                Inventory_Supplier inventory_Supplier4 = new Inventory_Supplier();
                inventory_Supplier4.Id = Guid.NewGuid().ToString();
                inventory_Supplier4.InventoryItemId = item4.Id;
                inventory_Supplier4.SupplierId      = supplier1.Id;
                inventory_Supplier4.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier4);

                Inventory_Supplier inventory_Supplier5 = new Inventory_Supplier();
                inventory_Supplier5.Id = Guid.NewGuid().ToString();
                inventory_Supplier5.InventoryItemId = item5.Id;
                inventory_Supplier5.SupplierId      = supplier2.Id;
                inventory_Supplier5.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier5);

                Inventory_Supplier inventory_Supplier6 = new Inventory_Supplier();
                inventory_Supplier6.Id = Guid.NewGuid().ToString();
                inventory_Supplier6.InventoryItemId = item6.Id;
                inventory_Supplier6.SupplierId      = supplier2.Id;
                inventory_Supplier6.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier6);

                Inventory_Supplier inventory_Supplier7 = new Inventory_Supplier();
                inventory_Supplier7.Id = Guid.NewGuid().ToString();
                inventory_Supplier7.InventoryItemId = item7.Id;
                inventory_Supplier7.SupplierId      = supplier2.Id;
                inventory_Supplier7.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier7);

                Inventory_Supplier inventory_Supplier8 = new Inventory_Supplier();
                inventory_Supplier8.Id = Guid.NewGuid().ToString();
                inventory_Supplier8.InventoryItemId = item8.Id;
                inventory_Supplier8.SupplierId      = supplier3.Id;
                inventory_Supplier8.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier8);

                Inventory_Supplier inventory_Supplier9 = new Inventory_Supplier();
                inventory_Supplier9.Id = Guid.NewGuid().ToString();
                inventory_Supplier9.InventoryItemId = item9.Id;
                inventory_Supplier9.SupplierId      = supplier3.Id;
                inventory_Supplier9.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier9);

                Inventory_Supplier inventory_Supplier10 = new Inventory_Supplier();
                inventory_Supplier10.Id = Guid.NewGuid().ToString();
                inventory_Supplier10.InventoryItemId = item10.Id;
                inventory_Supplier10.SupplierId      = supplier3.Id;
                inventory_Supplier10.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier10);



                Departments EN = new Departments();
                EN.Id                = Guid.NewGuid().ToString();
                EN.DeptCode          = "ENGL";
                EN.DeptName          = "English Dept";
                EN.DeptHead          = "marine";
                EN.FaxNumber         = 0000000;
                EN.PhoneNumber       = 1121231231;
                EN.CollectionPointId = cp1.Id;
                dbcontext.Add(EN);

                Departments CS = new Departments();
                CS.Id                = Guid.NewGuid().ToString();
                CS.DeptCode          = "CPSC";
                CS.DeptName          = "ComputerScience";
                CS.DeptHead          = "tom";
                CS.FaxNumber         = 1111111;
                CS.PhoneNumber       = 116561231;
                CS.CollectionPointId = cp3.Id;
                dbcontext.Add(CS);

                Departments Comm = new Departments();
                Comm.Id                = Guid.NewGuid().ToString();
                Comm.DeptCode          = "ENGL";
                Comm.DeptName          = "Commerce Dept";
                Comm.DeptHead          = "emma";
                Comm.FaxNumber         = 222222;
                Comm.PhoneNumber       = 1121678231;
                Comm.CollectionPointId = cp2.Id;
                dbcontext.Add(Comm);

                Departments regr = new Departments();
                regr.Id                = Guid.NewGuid().ToString();
                regr.DeptCode          = "Regr";
                regr.DeptName          = "Registra Dept";
                regr.DeptHead          = "ava";
                regr.FaxNumber         = 3333333;
                regr.PhoneNumber       = 112129955231;
                regr.CollectionPointId = cp5.Id;
                dbcontext.Add(regr);

                Departments StationeryDept = new Departments();
                StationeryDept.Id                = Guid.NewGuid().ToString();
                StationeryDept.DeptCode          = "STAT";
                StationeryDept.DeptName          = "Stationery Dept";
                StationeryDept.DeptHead          = "marine";
                StationeryDept.PhoneNumber       = 65899999;
                StationeryDept.FaxNumber         = 444444;
                StationeryDept.CollectionPointId = cp1.Id;
                dbcontext.Add(StationeryDept);

                Employee employee1 = new Employee();
                employee1.Id    = Guid.NewGuid().ToString();
                employee1.Name  = "nhw";
                employee1.Email = "*****@*****.**";
                string emp1psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee1.Password      = emp1psw;
                employee1.Role          = Role.STORE_CLERK;
                employee1.DepartmentsId = StationeryDept.Id;
                dbcontext.Add(employee1);

                Employee employee2 = new Employee();
                employee2.Id    = Guid.NewGuid().ToString();
                employee2.Name  = "wpa";
                employee2.Email = "*****@*****.**";
                string emp2psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee2.Password      = emp2psw;
                employee2.Role          = Role.STORE_SUPERVISOR;
                employee2.DepartmentsId = StationeryDept.Id;
                dbcontext.Add(employee2);

                Employee employee3 = new Employee();
                employee3.Id    = Guid.NewGuid().ToString();
                employee3.Name  = "keith";
                employee3.Email = "*****@*****.**";
                string emp3psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee3.Password      = emp3psw;
                employee3.Role          = Role.STORE_MANAGER;
                employee3.DepartmentsId = StationeryDept.Id;
                dbcontext.Add(employee3);

                Employee employee4 = new Employee();
                employee4.Id    = Guid.NewGuid().ToString();
                employee4.Name  = "tom";
                employee4.Email = "*****@*****.**";
                string emp4psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee4.Password      = emp4psw;
                employee4.Role          = Role.DEPT_HEAD;
                employee4.DepartmentsId = EN.Id;
                dbcontext.Add(employee4);

                Employee employee5 = new Employee();
                employee5.Id    = Guid.NewGuid().ToString();
                employee5.Name  = "tessa";
                employee5.Email = "*****@*****.**";
                string emp5psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee5.Password      = emp5psw;
                employee5.Role          = Role.DEPT_REP;
                employee5.DepartmentsId = EN.Id;
                dbcontext.Add(employee5);

                Employee employee6 = new Employee();
                employee6.Id    = Guid.NewGuid().ToString();
                employee6.Name  = "kk";
                employee6.Email = "*****@*****.**";
                string emp6psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee6.Password      = emp6psw;
                employee6.Role          = Role.EMPLOYEE;
                employee6.DepartmentsId = EN.Id;
                dbcontext.Add(employee6);


                Employee employee7 = new Employee();
                employee7.Id    = Guid.NewGuid().ToString();
                employee7.Name  = "marine1";
                employee7.Email = "*****@*****.**";
                string emp7psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee7.Password      = emp7psw;
                employee7.Role          = Role.DEPT_HEAD;
                employee7.DepartmentsId = CS.Id;
                dbcontext.Add(employee7);

                Employee employee8 = new Employee();
                employee8.Id    = Guid.NewGuid().ToString();
                employee8.Name  = "noah";
                employee8.Email = "*****@*****.**";
                string emp8psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee8.Password      = emp8psw;
                employee8.Role          = Role.DEPT_REP;
                employee8.DepartmentsId = CS.Id;
                dbcontext.Add(employee8);

                Employee employee9 = new Employee();
                employee9.Id    = Guid.NewGuid().ToString();
                employee9.Name  = "liam";
                employee9.Email = "*****@*****.**";
                string emp9psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee9.Password      = emp9psw;
                employee9.Role          = Role.EMPLOYEE;
                employee9.DepartmentsId = CS.Id;
                dbcontext.Add(employee9);


                Employee employee10 = new Employee();
                employee10.Id    = Guid.NewGuid().ToString();
                employee10.Name  = "emma";
                employee10.Email = "*****@*****.**";
                string emp10psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee10.Password      = emp10psw;
                employee10.Role          = Role.DEPT_HEAD;
                employee10.DepartmentsId = Comm.Id;
                dbcontext.Add(employee10);

                Employee employee11 = new Employee();
                employee11.Id    = Guid.NewGuid().ToString();
                employee11.Name  = "willian";
                employee11.Email = "*****@*****.**";
                string emp11psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee11.Password      = emp11psw;
                employee11.Role          = Role.DEPT_REP;
                employee11.DepartmentsId = Comm.Id;
                dbcontext.Add(employee11);

                Employee employee12 = new Employee();
                employee12.Id    = Guid.NewGuid().ToString();
                employee12.Name  = "james";
                employee12.Email = "*****@*****.**";
                string emp12psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee12.Password      = emp12psw;
                employee12.Role          = Role.EMPLOYEE;
                employee12.DepartmentsId = Comm.Id;
                dbcontext.Add(employee12);


                Employee employee13 = new Employee();
                employee13.Id    = Guid.NewGuid().ToString();
                employee13.Name  = "ava";
                employee13.Email = "*****@*****.**";
                string emp13psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee13.Password      = emp13psw;
                employee13.Role          = Role.DEPT_HEAD;
                employee13.DepartmentsId = regr.Id;
                dbcontext.Add(employee13);

                Employee employee14 = new Employee();
                employee14.Id    = Guid.NewGuid().ToString();
                employee14.Name  = "isabella";
                employee14.Email = "*****@*****.**";
                string emp14psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee14.Password      = emp14psw;
                employee14.Role          = Role.DEPT_REP;
                employee14.DepartmentsId = regr.Id;
                dbcontext.Add(employee14);

                Employee employee15 = new Employee();
                employee15.Id    = Guid.NewGuid().ToString();
                employee15.Name  = "liam";
                employee15.Email = "*****@*****.**";
                string emp15psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee15.Password      = emp15psw;
                employee15.Role          = Role.EMPLOYEE;
                employee15.DepartmentsId = regr.Id;
                dbcontext.Add(employee15);

                Requisition requisition1 = new Requisition();
                requisition1.Id                 = EN.DeptCode + "_" + DateTime.Now.ToString("MM/dd/yyyy/HH:mm:ss");
                requisition1.DepartmentId       = EN.Id;
                requisition1.EmployeeId         = employee6.Id;
                requisition1.ApprovedEmployeeId = employee4.Id;
                requisition1.DateSubmitted      = DateTime.Now;
                requisition1.status             = ReqStatus.APPROVED;
                requisition1.Remarks            = "nothing";
                dbcontext.Add(requisition1);

                RequisitionDetail requisition1Detail = new RequisitionDetail();
                requisition1Detail.Id             = Guid.NewGuid().ToString();
                requisition1Detail.RequisitionId  = requisition1.Id;
                requisition1Detail.InventoryId    = item1.Id;
                requisition1Detail.RequestedQty   = 20;
                requisition1Detail.DistributedQty = 0;
                dbcontext.Add(requisition1Detail);

                RequisitionDetail requisition1Detail2 = new RequisitionDetail();
                requisition1Detail2.Id             = Guid.NewGuid().ToString();
                requisition1Detail2.RequisitionId  = requisition1.Id;
                requisition1Detail2.InventoryId    = item2.Id;
                requisition1Detail2.RequestedQty   = 20;
                requisition1Detail2.DistributedQty = 0;
                dbcontext.Add(requisition1Detail2);
//----------------------------------------------------------------------------------------------------------------------------------> Keith
                Requisition requisition11 = new Requisition();
                requisition11.Id                 = EN.DeptCode + "_" + DateTime.Now;
                requisition11.DepartmentId       = EN.Id;
                requisition11.EmployeeId         = employee6.Id;
                requisition11.ApprovedEmployeeId = employee4.Id;
                requisition11.DateSubmitted      = DateTime.Now;
                requisition11.status             = ReqStatus.APPROVED;
                requisition11.Remarks            = "nothing";
                dbcontext.Add(requisition11);

                RequisitionDetail requisition1Detail11 = new RequisitionDetail();
                requisition1Detail.Id             = Guid.NewGuid().ToString();
                requisition1Detail.RequisitionId  = requisition11.Id;
                requisition1Detail.InventoryId    = item1.Id;
                requisition1Detail.RequestedQty   = 20;
                requisition1Detail.DistributedQty = 0;
                dbcontext.Add(requisition1Detail);

                RequisitionDetail requisition1Detail12 = new RequisitionDetail();
                requisition1Detail2.Id             = Guid.NewGuid().ToString();
                requisition1Detail2.RequisitionId  = requisition11.Id;
                requisition1Detail2.InventoryId    = item2.Id;
                requisition1Detail2.RequestedQty   = 20;
                requisition1Detail2.DistributedQty = 0;
                dbcontext.Add(requisition1Detail2);
//----------------------------------------------------------------------------------------------------------------------------------> Keith
                Requisition requisition2 = new Requisition();
                requisition2.Id                 = CS.DeptCode + "_" + DateTime.Now.ToString("MM/dd/yyyy/HH:mm:ss");
                requisition2.DepartmentId       = CS.Id;
                requisition2.EmployeeId         = employee9.Id;
                requisition2.ApprovedEmployeeId = employee7.Id;
                requisition2.DateSubmitted      = DateTime.Now;
                requisition2.status             = ReqStatus.OUTSTAND;
                requisition2.Remarks            = "nothing";
                dbcontext.Add(requisition2);

                Requisition requisition3 = new Requisition();
                requisition3.Id                 = regr.DeptCode + "_" + DateTime.Now.ToString("MM/dd/yyyy/HH:mm:ss");
                requisition3.DepartmentId       = regr.Id;
                requisition3.EmployeeId         = employee15.Id;
                requisition3.ApprovedEmployeeId = employee13.Id;
                requisition3.DateSubmitted      = DateTime.Now;
                requisition3.status             = ReqStatus.REJECTED;
                requisition3.Remarks            = "nothing";
                dbcontext.Add(requisition3);

                Requisition requisition4 = new Requisition();
                requisition4.Id                 = regr.DeptCode + "_" + DateTime.Now;
                requisition4.DepartmentId       = regr.Id;
                requisition4.EmployeeId         = employee15.Id;
                requisition4.ApprovedEmployeeId = employee13.Id;
                requisition4.DateSubmitted      = DateTime.Now;
                requisition4.status             = ReqStatus.PROCESSING;
                requisition4.Remarks            = "nothing";
                dbcontext.Add(requisition4);

/*                Requisition rq1 = new Requisition();
 *              rq1.Id = Comm.DeptCode + "_" + DateTime.Now;
 *              rq1.ApprovedEmployee = employee10;
 *              rq1.DepartmentId = Comm.Id;
 *              rq1.Employee = employee12;
 *              rq1.DateSubmitted = DateTime.Today;
 *              rq1.status = ReqStatus.APPROVED;
 *              dbcontext.Add(rq1);
 *
 *
 *              RequisitionDetail rqd1 = new RequisitionDetail();
 *              rqd1.Id = Guid.NewGuid().ToString();
 *              rqd1.Requisition = rq1;
 *              rqd1.Inventory = item8;
 *              rqd1.RequestedQty = 88;
 *              dbcontext.Add(rqd1);
 *
 *              RequisitionDetail rqd2 = new RequisitionDetail();
 *              rqd2.Id = Guid.NewGuid().ToString();
 *              rqd2.Requisition = rq1;
 *              rqd2.Inventory = item7;
 *              rqd2.RequestedQty = 77;
 *              dbcontext.Add(rqd2);
 *
 *              RequisitionDetail rqd3 = new RequisitionDetail();
 *              rqd3.Id = Guid.NewGuid().ToString();
 *              rqd3.Requisition = rq1;
 *              rqd3.Inventory = item5;
 *              rqd3.RequestedQty = 55;
 *              dbcontext.Add(rqd3);
 *
 *              Requisition rq2 = new Requisition();
 *              rq2.Id = Comm.DeptCode + "_" + DateTime.Now;
 *              rq2.ApprovedEmployee = employee10;
 *              rq2.DepartmentId = Comm.Id;
 *              rq2.Employee = employee12;
 *              rq2.DateSubmitted = DateTime.Today;
 *              rq2.status = ReqStatus.APPROVED;
 *              dbcontext.Add(rq2);
 *
 *              RequisitionDetail rqd4 = new RequisitionDetail();
 *              rqd4.Id = Guid.NewGuid().ToString();
 *              rqd4.Requisition = rq2;
 *              rqd4.Inventory = item4;
 *              rqd4.RequestedQty = 44;
 *              dbcontext.Add(rqd4);
 *
 *              RequisitionDetail rqd5 = new RequisitionDetail();
 *              rqd5.Id = Guid.NewGuid().ToString();
 *              rqd5.Requisition = rq2;
 *              rqd5.Inventory = item5;
 *              rqd5.RequestedQty = 55;
 *              dbcontext.Add(rqd5);
 *
 *              RequisitionDetail rqd6 = new RequisitionDetail();
 *              rqd6.Id = Guid.NewGuid().ToString();
 *              rqd6.Requisition = rq2;
 *              rqd6.Inventory = item7;
 *              rqd6.RequestedQty = 30;
 *              dbcontext.Add(rqd6);
 *
 *              Requisition rq3 = new Requisition();
 *              rq3.Id = EN.DeptCode + "_" + DateTime.Now;
 *              rq3.ApprovedEmployee = employee4;
 *              rq3.DepartmentId = EN.Id;
 *              rq3.Employee = employee6;
 *              rq3.DateSubmitted = DateTime.Today;
 *              rq3.status = ReqStatus.APPROVED;
 *              dbcontext.Add(rq3);
 *
 *              RequisitionDetail rqd7 = new RequisitionDetail();
 *              rqd7.Id = Guid.NewGuid().ToString();
 *              rqd7.Requisition = rq3;
 *              rqd7.RequisitionId = rq3.Id;
 *              rqd7.Inventory = item5;
 *              rqd7.RequestedQty = 50;
 *              dbcontext.Add(rqd7);
 *
 *              RequisitionDetail rqd8 = new RequisitionDetail();
 *              rqd8.Id = Guid.NewGuid().ToString();
 *              rqd8.Requisition = rq3;
 *              rqd8.RequisitionId = rq3.Id;
 *              rqd8.Inventory = item4;
 *              rqd8.RequestedQty = 50;
 *              dbcontext.Add(rqd8);
 *
 *              RequisitionDetail rqd9 = new RequisitionDetail();
 *              rqd9.Id = Guid.NewGuid().ToString();
 *              rqd9.Requisition = rq3;
 *              rqd9.RequisitionId = rq3.Id;
 *              rqd9.Inventory = item1;
 *              rqd9.RequestedQty = 50;
 *              dbcontext.Add(rqd8);*/

                dbcontext.SaveChanges();
            }
        }
        public ActionResult Edit(List <RForm> commitedRetrievalForm, string sessionId)
        {
            if (sessionId == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            StoreClerk      storeclerk      = db.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreManager    storeManager    = db.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreSupervisor storeSupervisor = db.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault();

            if (ModelState.IsValid)
            {
                List <string> departmentList       = new List <string>();
                int           outstandingListCount = db.OutstandingLists.Count();

                //update retrieval form status to "Submitted"
                StationeryRetrievalForm existingStationeryRetrievalForm = db.StationeryRetrievalForms.Find(commitedRetrievalForm[0].stationeryRetrievalFormDetail.FormNumber);
                existingStationeryRetrievalForm.Status = "Submitted";

                foreach (RForm commitedFormDetail in commitedRetrievalForm)
                {
                    //Update actual values into retrieval form details
                    StationeryRetrievalFormDetail existingStationeryRetrievalFormDetail = db.StationeryRetrievalFormDetails.Find(commitedFormDetail.stationeryRetrievalFormDetail.FormDetailsNumber);
                    existingStationeryRetrievalFormDetail.Actual = commitedFormDetail.stationeryRetrievalFormDetail.Actual;

                    //update stationery catalog
                    StationeryCatalog existingCatalog = db.StationeryCatalogs.Find(commitedFormDetail.stationeryRetrievalFormDetail.ItemNumber);
                    existingCatalog.Balance -= commitedFormDetail.stationeryRetrievalFormDetail.Actual;

                    //add the department code to our department list created above, to generate disbursement list by department below
                    if (!departmentList.Contains(commitedFormDetail.stationeryRetrievalFormDetail.DepartmentCode))
                    {
                        departmentList.Add(commitedFormDetail.stationeryRetrievalFormDetail.DepartmentCode);
                    }

                    //If insufficient inventory, generate a outstanding list object for each retrieval form detail
                    if (commitedFormDetail.stationeryRetrievalFormDetail.Needed > commitedFormDetail.stationeryRetrievalFormDetail.Actual)
                    {
                        outstandingListCount++;

                        OutstandingList outstandingItem = new OutstandingList
                        {
                            OutstandingListNumber      = outstandingListCount.ToString(),
                            RetrievalFormDetailsNumber = commitedFormDetail.stationeryRetrievalFormDetail.FormDetailsNumber,
                            Status = "Outstanding"
                        };
                        db.OutstandingLists.Add(outstandingItem);
                    }

                    db.SaveChanges();
                }

                //create a single disbursement list for each department
                foreach (string deptCode in departmentList)
                {
                    DisbursementList dl = new DisbursementList
                    {
                        ListNumber     = (db.DisbursementLists.Count() + 1).ToString(),
                        DepartmentCode = deptCode,
                        Date           = DateTime.Today,
                        Status         = "Pending"
                    };
                    db.DisbursementLists.Add(dl);
                    db.SaveChanges();

                    DepartmentList  dept         = db.DepartmentLists.Where(x => x.DepartmentCode == deptCode).FirstOrDefault();
                    string          Eid          = dept.RepresentativeId;
                    Employee        repo         = db.Employees.Find(Eid);
                    string          emailAddress = repo.EmailAddress;
                    string          pointId      = dept.CollectionPoint;
                    CollectionPoint point        = db.CollectionPoints.Find(pointId);
                    string          subject      = "Your items are ready for collection";
                    string          message      = "<p>Dear " + repo.UserName + "." + "</p><br/><p>Your items are ready for collection</p><br/><p>Collection point and time: " + point.CollectionPointName + "---" + point.CollectionTime + "</p><br/><p>Stationery Management Team</p>";
                    util.SendEmail(emailAddress, subject, message);

                    int disbursementListDetailsCount = db.DisbursementListDetails.Count();

                    foreach (RForm commitedFormDetail in commitedRetrievalForm)
                    {
                        if (commitedFormDetail.stationeryRetrievalFormDetail.DepartmentCode.Equals(deptCode))
                        {
                            disbursementListDetailsCount++;

                            DisbursementListDetail dld = new DisbursementListDetail
                            {
                                ListDetailsNumber = disbursementListDetailsCount.ToString(),
                                ListNumber        = dl.ListNumber,
                                ItemNumber        = commitedFormDetail.stationeryRetrievalFormDetail.ItemNumber,
                                Quantity          = commitedFormDetail.stationeryRetrievalFormDetail.Actual
                            };

                            db.DisbursementListDetails.Add(dld);
                            db.SaveChanges();
                        }
                    }
                }
                return(RedirectToAction("Index", "StationeryRetrievalForms", new { sessionId = sessionId }));
            }

            if (storeclerk != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]  = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["sessionId"] = storeclerk.SessionId;
                ViewData["username"]  = storeclerk.UserName;

                return(View(commitedRetrievalForm));
            }
            else if (storeManager != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]  = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["sessionId"] = storeManager.SessionId;
                ViewData["username"]  = storeManager.UserName;
                return(View(commitedRetrievalForm));
            }
            else if (storeSupervisor != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]  = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["sessionId"] = storeSupervisor.SessionId;
                ViewData["username"]  = storeSupervisor.UserName;
                return(View(commitedRetrievalForm));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
        public List <Department> FindDeptsByCollectionPointId(string cpId)
        {
            CollectionPoint cp = cpServ.GetCollectionPointById(cpId);

            return(deptServ.SearchDepartmentByLocationId(cp.LocationId));
        }
Ejemplo n.º 7
0
 public void InsertCollectionPoint(CollectionPoint collectionPoint)
 {
     context.CollectionPoints.Add(collectionPoint);
 }
Ejemplo n.º 8
0
        public CollectionPoint GetCollectionPointById(string id)
        {
            CollectionPoint cp = se.CollectionPoints.Where(x => x.LocationId == id).First();

            return(cp);
        }
Ejemplo n.º 9
0
        public DBSeeder(ADProjContext dbcontext)
        {
            //test
            //Collectionpoint seeder
            CollectionPoint cp1 = new CollectionPoint()
            {
                Id         = Guid.NewGuid().GetHashCode(),
                Name       = "Science Lobby 1",
                Time       = new System.DateTime(2020, 1, 1, 1, 13, 30, 00),
                EmployeeId = 3
            };

            dbcontext.Add(cp1);


            //Department seeder
            Department department1 = new Department()
            {
                Id                         = Guid.NewGuid().ToString(),
                Name                       = "Science",
                DepartmentHeadId           = 1,
                DepartmentRepresentativeId = 1,
                CollectionPointId          = "1"
            };

            dbcontext.Add(department1);



            //Employee seeder
            Employee employee1 = new Employee()
            {
                Id           = Guid.NewGuid().GetHashCode(),
                DepartmentId = "1",
                Role         = "Employee",
                Name         = "John",
                Email        = "*****@*****.**",
                Password     = "******"
            };

            dbcontext.Add(employee1);

            Employee employee2 = new Employee()
            {
                Id           = Guid.NewGuid().GetHashCode(),
                DepartmentId = "1",
                Role         = "Manager",
                Name         = "David",
                Email        = "*****@*****.**",
                Password     = "******"
            };

            dbcontext.Add(employee2);

            Employee employee3 = new Employee()
            {
                Id           = Guid.NewGuid().GetHashCode(),
                DepartmentId = "1",
                Role         = "Employee",
                Name         = "Janice",
                Email        = "*****@*****.**",
                Password     = "******"
            };

            dbcontext.Add(employee3);

            dbcontext.SaveChanges();
        }
Ejemplo n.º 10
0
 public void Create(CollectionPoint cp)
 {
     context.CollectionPoints.Add(cp);
     context.SaveChanges();
 }
Ejemplo n.º 11
0
        public ActionResult IndexCollectionPoint(int? page, int? pagesize, string name, string first)
        {
            dynamic data = new System.Dynamic.ExpandoObject();
            if (name == null) name = "";
            var list = _CollectionPointRepos.GetAllCollectionPoint(name);

            int _page = page.HasValue ? page.Value : 1;
            int _pagesize = pagesize.HasValue ? pagesize.Value : 12;
            var vs = list.ToPagedList(_page, _pagesize);
            var firstone = new CollectionPoint();
            if (first != null && first != "")
            {
                firstone = list.FirstOrDefault(p => p.CollectionPointCode == first);
                var firspage = vs.IndexOf(firstone);
                if (firspage == -1)
                {
                    vs.Insert(0, firstone);
                }
                else if (firspage > 0)
                {
                    vs.Remove(firstone);
                    vs.Insert(0, firstone);
                }
            }
            data.name = name;
            data.list = vs;
            data.pageSize = _pagesize;
            data.pageIndex = _page;
            data.totalCount = vs.TotalCount;
            string otherparam = "";
            if (name != "") otherparam += "&name=" + name;
            data.otherParam = otherparam;
            return PartialView(data);
        }
Ejemplo n.º 12
0
        protected void ui_save_button_Click(object sender, EventArgs e)
        {
            CollectionPoint collectionPoint = new CollectionPoint();
            int             collectionPoint_id;

            if (int.TryParse(ui_id_hiddenfield.Value, out collectionPoint_id))
            {
                collectionPoint.id = Convert.ToInt32(ui_id_hiddenfield.Value);
            }
            if (String.IsNullOrEmpty(ui_collectionPoint_textbox.Text))
            {
                Response.Cookies.Add(new HttpCookie("flash_message", "Field(s) marked with * can't be empty.")
                {
                    Path = "/"
                });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error")
                {
                    Path = "/"
                });
                return;
            }

            collectionPoint.name = ui_collectionPoint_textbox.Text;

            Message message;

            if (collectionPoint.id > 0)
            {
                message = collectionPointController.actionUpdateCollectionPoint(collectionPoint);
            }
            else
            {
                message = collectionPointController.actionCreateCollectionPoint(collectionPoint);
            }

            //redirecting
            if (message.condition)
            {
                Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Saved.")
                {
                    Path = "/"
                });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success")
                {
                    Path = "/"
                });
                Response.Redirect("~/StoreClerk/CollectionPointDetail.aspx?id=" + collectionPoint.id);
            }
            else
            {
                Response.Cookies.Add(new HttpCookie("flash_message", message.message)
                {
                    Path = "/"
                });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error")
                {
                    Path = "/"
                });
                Response.Redirect("~/StoreClerk/CollectionPointDetail.aspx?id=" + collectionPoint.id);
            }
        }
Ejemplo n.º 13
0
        public CollectionPoint GetDeptCollectionPoint(Department dp)
        {
            CollectionPoint cp = dbcontext.CollectionPoints.Where(m => m.Id == dp.CollectionPointId).FirstOrDefault();

            return(cp);
        }
Ejemplo n.º 14
0
        public CollectionPoint GetStoreCollectionPoint()
        {
            CollectionPoint storecp = dbcontext.CollectionPoints.Where(m => m.Id == 6).FirstOrDefault();

            return(storecp);
        }
Ejemplo n.º 15
0
 public void UpdateCollectionPoint(Department dept, CollectionPoint CP)
 {
     dept.collectionPointID = CP.collectionPointID;
     context.SaveChanges();
 }
        public void RetrieveDeptId(Dept_Staff user, FormCollection form)
        {
            int deptId = user.DeptId;
            //  int deptIdInForm = int.Parse(form["Department"]);
            var reqs = db.Departments.Select(i => i.DeptId == deptId);

            if (reqs == null)
            {
                Dictionary <int, int>       dictionary = new Dictionary <int, int>();
                ConsolidatedRequestsService daoObj     = new ConsolidatedRequestsService();
                dictionary = daoObj.ConsolidateIndividualRequests(deptId);
                List <CollectionOfRequestedItems> CollectionOfReqList =
                    new List <CollectionOfRequestedItems>();
                foreach (var i in dictionary)
                {
                    CollectionOfRequestedItems collectionOfReq = new CollectionOfRequestedItems();
                    collectionOfReq.ItemId            = i.Key;
                    collectionOfReq.TotalRequestedQty = i.Value;
                    db.collectionOfRequestedItems.Add(collectionOfReq);
                    CollectionOfReqList.Add(collectionOfReq);
                }
                ConsolidatedRequisition cons = new ConsolidatedRequisition();

                CollectionPoint coll = new CollectionPoint();
                coll.CollectionPointId = int.Parse(form["CollectionPoint"]);


                Department dept = new Department();
                dept.DeptId = deptId;


                cons.CollectionPoint = coll;
                cons.Department      = dept;
                cons.CollectionOfReq = CollectionOfReqList;
                cons.ConsolidatedRequisitionStatus = "Approved";
                cons.RequestedDate = DateTime.Now;
                db.ConsolidatedRequisitions.Add(cons);
                var empReqs = db.EmployeeRequestForms.Include(i => i.RequestItems.Select(it => it.Item)).Where(n => n.EmployeeRequestFormstatus == "Approved");

                foreach (var e in empReqs)
                {
                    e.EmployeeRequestFormstatus = "Consolidated";
                }
                db.SaveChanges();
            }
            else
            {
                Dictionary <int, int>       dictionary = new Dictionary <int, int>();
                ConsolidatedRequestsService daoObj     = new ConsolidatedRequestsService();
                dictionary = daoObj.ConsolidateIndividualRequests(deptId);
                List <CollectionOfRequestedItems> CollectionOfReqList =
                    new List <CollectionOfRequestedItems>();
                foreach (var i in dictionary)
                {
                    CollectionOfRequestedItems collectionOfReq = new CollectionOfRequestedItems();
                    collectionOfReq.ItemId            = i.Key;
                    collectionOfReq.TotalRequestedQty = i.Value;
                    db.collectionOfRequestedItems.Add(collectionOfReq);
                    CollectionOfReqList.Add(collectionOfReq);
                }
                ConsolidatedRequisition cons = new ConsolidatedRequisition();
                cons.CollectionPointId = int.Parse(form["CollectionPoint"]);


                //    int deptId = user.DeptId;
                cons.deptId = deptId;

                cons.CollectionOfReq = CollectionOfReqList;
                cons.ConsolidatedRequisitionStatus = "Approved";
                cons.RequestedDate = DateTime.Now;
                db.ConsolidatedRequisitions.Add(cons);

                var empReqs = db.EmployeeRequestForms.Include(i => i.RequestItems.Select(it => it.Item)).Where(n => n.EmployeeRequestFormstatus == "Approved");

                foreach (var e in empReqs)
                {
                    e.EmployeeRequestFormstatus = "Consolidated";
                }
                db.SaveChanges();
            }
        }
Ejemplo n.º 17
0
        public static CollectionPoint getcollectionpoint(string g)
        {
            CollectionPoint cp = CollectionPointEFFacade.getcollectionpointfromname(g);

            return(cp);
        }
        public ActionResult Details(string id, string sessionId, string errorMeg)
        {
            if (sessionId == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            StoreClerk      storeclerk      = db.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreManager    storeManager    = db.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreSupervisor storeSupervisor = db.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault();

            List <DisbursementList>       disbursementLists       = db.DisbursementLists.ToList();
            List <DisbursementListDetail> disbursementListDetails = db.DisbursementListDetails.ToList();
            List <StationeryCatalog>      stationeryCatalogs      = db.StationeryCatalogs.ToList();
            var disbursementDetailRecord = (from d in disbursementListDetails
                                            join l in disbursementLists on d.ListNumber equals l.ListNumber into table1
                                            from l in table1.ToList()
                                            join s in stationeryCatalogs on d.ItemNumber equals s.ItemNumber into table2
                                            from s in table2.ToList()
                                            select new ViewModelDDetails
            {
                disbursementList = l,
                disbursementListDetail = d,
                stationeryCatalog = s,
            }).Where(x => x.disbursementList.ListNumber == id).ToList();


            if (disbursementDetailRecord.Count() == 0)
            {
                return(RedirectToAction("Index", "DisbursementLists", new { @sessionId = sessionId }));
            }
            DisbursementList disbursementList = db.DisbursementLists.Where(d => d.ListNumber == id).Single();
            DepartmentList   departmentList   = db.DepartmentLists.Where(d => d.DepartmentCode == disbursementList.DepartmentCode).Single();
            CollectionPoint  collectionPoint  = db.CollectionPoints.Where(c => c.CollectionPointCode == departmentList.CollectionPoint).Single();
            Employee         employee         = db.Employees.Where(e => e.Id == departmentList.RepresentativeId).Single();


            if (storeclerk != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]         = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["collection"]       = collectionPoint.CollectionPointName;
                ViewData["disbursementList"] = disbursementList.Date;
                ViewData["deparment"]        = departmentList.DepartmentName;
                ViewData["employeeF"]        = employee.FirstName;
                ViewData["employeeL"]        = employee.LastName;
                ViewData["sessionId"]        = storeclerk.SessionId;
                ViewData["username"]         = storeclerk.UserName;
                ViewData["tag"]      = "storeclerk";
                ViewData["errorMeg"] = errorMeg;
                return(View(disbursementDetailRecord));
            }
            else if (storeManager != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]         = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["collection"]       = collectionPoint.CollectionPointName;
                ViewData["disbursementList"] = disbursementList.Date;
                ViewData["deparment"]        = departmentList.DepartmentName;
                ViewData["employeeF"]        = employee.FirstName;
                ViewData["employeeL"]        = employee.LastName;
                ViewData["sessionId"]        = storeManager.SessionId;
                ViewData["username"]         = storeManager.UserName;
                ViewData["tag"]      = "storeManager";
                ViewData["errorMeg"] = errorMeg;
                return(View(disbursementDetailRecord));
            }
            else if (storeSupervisor != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]         = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["collection"]       = collectionPoint.CollectionPointName;
                ViewData["disbursementList"] = disbursementList.Date;
                ViewData["deparment"]        = departmentList.DepartmentName;
                ViewData["employeeF"]        = employee.FirstName;
                ViewData["employeeL"]        = employee.LastName;
                ViewData["sessionId"]        = storeSupervisor.SessionId;
                ViewData["username"]         = storeSupervisor.UserName;
                ViewData["tag"]      = "storeSupervisor";
                ViewData["errorMeg"] = errorMeg;
                return(View(disbursementDetailRecord));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Index()
        {
            string name = "Clerk's Name";

            using (var httpClient = new HttpClient())
            {
                int id = (int)HttpContext.Session.GetInt32("UserID");
                using (var response = await httpClient.GetAsync(api_url))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    name = apiResponse;
                }

                using (var response = await httpClient.GetAsync(api_url + "get-top-summed/"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    topSixRequested = JsonConvert.DeserializeObject <List <TopSixRequested> >(apiResponse);
                }
                using (var response = await httpClient.GetAsync(api_url_rqst + "/" + "GetRequestCountByStatus" + "/" + "PendingDelivery"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    pendingDeliveries = JsonConvert.DeserializeObject <int>(apiResponse);
                }
                using (var response = await httpClient.GetAsync(api_url_rqst + "/" + "GetRequestCountByStatus" + "/" + "Approved"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    newRequests = JsonConvert.DeserializeObject <int>(apiResponse);
                }

                using (var response = await httpClient.GetAsync(api_url + "get-clerk-pending/" + id))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    pendingAdjustments = Int32.Parse(apiResponse);
                }

                using (var response = await httpClient.GetAsync(api_url + "get-next-collection-time-location/"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    nextCollectionPoint = JsonConvert.DeserializeObject <CollectionPoint>(apiResponse);
                }
                using (var response = await httpClient.GetAsync(api_url + "get-next-collection-datetime/"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    nextCollectionDate = JsonConvert.DeserializeObject <DateTime>(apiResponse);
                }
                using (var response = await httpClient.GetAsync(api_url + "get-low-stock-item-count/"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    lowStockItemCount = Int32.Parse(apiResponse);
                }
            }
            ViewData["name"]                = name;
            ViewData["topSixRequested"]     = topSixRequested;
            ViewData["newRequests"]         = newRequests;
            ViewData["pendingDeliveries"]   = pendingDeliveries;
            ViewData["pendingAdjustments"]  = pendingAdjustments;
            ViewData["nextCollectionPoint"] = nextCollectionPoint;
            ViewData["nextCollectionDate"]  = nextCollectionDate;
            ViewData["lowStockItemCount"]   = lowStockItemCount;

            return(View("ClerkDash"));
        }
Ejemplo n.º 20
0
        public DbSeeder(StationeryContext dbcontext)
        {
            using (MD5 md5Hash = MD5.Create())
            {
                string          time1 = "9:30am";
                string          time2 = "11:00am";
                CollectionPoint cp1   = new CollectionPoint();
                cp1.Id       = Guid.NewGuid().ToString();
                cp1.Location = "Stationery Store - Administration Building";
                cp1.Time     = time1;
                dbcontext.Add(cp1);

                CollectionPoint cp2 = new CollectionPoint();
                cp2.Id       = Guid.NewGuid().ToString();
                cp2.Location = "Management School";
                cp2.Time     = time2;
                dbcontext.Add(cp2);

                CollectionPoint cp3 = new CollectionPoint();
                cp3.Id       = Guid.NewGuid().ToString();
                cp3.Location = "Medical School";
                cp3.Time     = time1;
                dbcontext.Add(cp3);

                CollectionPoint cp4 = new CollectionPoint();
                cp4.Id       = Guid.NewGuid().ToString();
                cp4.Location = "Engineering School";
                cp4.Time     = time1;
                dbcontext.Add(cp4);

                CollectionPoint cp5 = new CollectionPoint();
                cp5.Id       = Guid.NewGuid().ToString();
                cp5.Location = "Science School";
                cp5.Time     = time1;
                dbcontext.Add(cp5);

                CollectionPoint cp6 = new CollectionPoint();
                cp6.Id       = Guid.NewGuid().ToString();
                cp6.Location = "University Hospital";
                cp6.Time     = time2;
                dbcontext.Add(cp6);


                ItemCategory category1 = new ItemCategory();
                category1.Id   = Guid.NewGuid().ToString();
                category1.name = "Clip";
                dbcontext.Add(category1);

                ItemCategory category2 = new ItemCategory();
                category2.Id   = Guid.NewGuid().ToString();
                category2.name = "Envelope";
                dbcontext.Add(category2);

                ItemCategory category3 = new ItemCategory();
                category3.Id   = Guid.NewGuid().ToString();
                category3.name = "Eraser";
                dbcontext.Add(category3);

                ItemCategory category4 = new ItemCategory();
                category4.Id   = Guid.NewGuid().ToString();
                category4.name = "Exercise";
                dbcontext.Add(category4);

                ItemCategory category5 = new ItemCategory();
                category5.Id   = Guid.NewGuid().ToString();
                category5.name = "File";
                dbcontext.Add(category5);

                ItemCategory category6 = new ItemCategory();
                category6.Id   = Guid.NewGuid().ToString();
                category6.name = "Pen";
                dbcontext.Add(category6);

                ItemCategory category7 = new ItemCategory();
                category7.Id   = Guid.NewGuid().ToString();
                category7.name = "Puncher";
                dbcontext.Add(category7);

                ItemCategory category8 = new ItemCategory();
                category8.Id   = Guid.NewGuid().ToString();
                category8.name = "Pad";
                dbcontext.Add(category8);

                ItemCategory category9 = new ItemCategory();
                category9.Id   = Guid.NewGuid().ToString();
                category9.name = "Paper";
                dbcontext.Add(category9);

                ItemCategory category10 = new ItemCategory();
                category10.Id   = Guid.NewGuid().ToString();
                category10.name = "Ruler";
                dbcontext.Add(category10);

                Inventory item1 = new Inventory();
                item1.Id              = Guid.NewGuid().ToString();
                item1.ItemCategoryId  = category1.Id;
                item1.itemCode        = "C001";
                item1.description     = "Clips Double 1";
                item1.stock           = 500;
                item1.measurementUnit = "Dozen";
                item1.location        = "bin01";
                item1.reorderLevel    = 50;
                item1.reorderQty      = 30;
                item1.price           = 1;
                dbcontext.Add(item1);

                Inventory item2 = new Inventory();
                item2.Id              = Guid.NewGuid().ToString();
                item2.ItemCategoryId  = category1.Id;
                item2.itemCode        = "C002";
                item2.description     = "Clips Double 2";
                item2.stock           = 500;
                item2.measurementUnit = "Dozen";
                item2.location        = "bin01";
                item2.reorderLevel    = 50;
                item2.reorderQty      = 30;
                item2.price           = 10;
                dbcontext.Add(item2);

                Inventory item3 = new Inventory();
                item3.Id              = Guid.NewGuid().ToString();
                item3.ItemCategoryId  = category1.Id;
                item3.itemCode        = "C003";
                item3.description     = "Clips Double 3/4";
                item3.stock           = 500;
                item3.measurementUnit = "Dozen";
                item3.location        = "bin01";
                item3.reorderLevel    = 50;
                item3.reorderQty      = 30;
                item3.price           = 2;
                dbcontext.Add(item3);

                Inventory item4 = new Inventory();
                item4.Id              = Guid.NewGuid().ToString();
                item4.ItemCategoryId  = category1.Id;
                item4.itemCode        = "C004";
                item4.description     = "Clips Paper Large";
                item4.stock           = 500;
                item4.measurementUnit = "Box";
                item4.location        = "bin01";
                item4.reorderLevel    = 50;
                item4.reorderQty      = 30;
                item4.price           = 3;
                dbcontext.Add(item4);

                Inventory item5 = new Inventory();
                item5.Id              = Guid.NewGuid().ToString();
                item5.ItemCategoryId  = category1.Id;
                item5.itemCode        = "C005";
                item5.description     = "Clips Paper Medium";
                item5.stock           = 500;
                item5.measurementUnit = "Box";
                item5.location        = "bin01";
                item5.reorderLevel    = 50;
                item5.reorderQty      = 30;
                item5.price           = 1.5;
                dbcontext.Add(item5);

                Inventory item6 = new Inventory();
                item6.Id              = Guid.NewGuid().ToString();
                item6.ItemCategoryId  = category1.Id;
                item6.itemCode        = "C006";
                item6.description     = "Clips Paper Small";
                item6.stock           = 500;
                item6.measurementUnit = "Box";
                item6.location        = "bin01";
                item6.reorderLevel    = 50;
                item6.reorderQty      = 30;
                item6.price           = 0.5;
                dbcontext.Add(item6);

                Inventory item7 = new Inventory();
                item7.Id              = Guid.NewGuid().ToString();
                item7.ItemCategoryId  = category2.Id;
                item7.itemCode        = "E001";
                item7.description     = "Envelope Brown(3x6)";
                item7.stock           = 500;
                item7.measurementUnit = "Each";
                item7.location        = "bin02";
                item7.reorderLevel    = 600;
                item7.reorderQty      = 400;
                item7.price           = 0.7;
                dbcontext.Add(item7);

                Inventory item8 = new Inventory();
                item8.Id              = Guid.NewGuid().ToString();
                item8.ItemCategoryId  = category2.Id;
                item8.itemCode        = "E002";
                item8.description     = "Envelope Brown(3x6) w/Window";
                item8.stock           = 500;
                item8.measurementUnit = "Each";
                item8.location        = "bin02";
                item8.reorderLevel    = 600;
                item8.reorderQty      = 400;
                item8.price           = 0.9;
                dbcontext.Add(item8);

                Inventory item9 = new Inventory();
                item9.Id              = Guid.NewGuid().ToString();
                item9.ItemCategoryId  = category2.Id;
                item9.itemCode        = "E003";
                item9.description     = "Envelope Brown(5x7)";
                item9.stock           = 500;
                item9.measurementUnit = "Each";
                item9.location        = "bin02";
                item9.reorderLevel    = 600;
                item9.reorderQty      = 400;
                item9.price           = 0.8;
                dbcontext.Add(item9);

                Inventory item10 = new Inventory();
                item10.Id              = Guid.NewGuid().ToString();
                item10.ItemCategoryId  = category2.Id;
                item10.itemCode        = "E004";
                item10.description     = "Envelope Brown(5x7) w/Window";
                item10.stock           = 500;
                item10.measurementUnit = "Each";
                item10.location        = "bin02";
                item10.reorderLevel    = 600;
                item10.reorderQty      = 400;
                item10.price           = 1.1;
                dbcontext.Add(item10);

                Inventory item11 = new Inventory();
                item11.Id              = Guid.NewGuid().ToString();
                item11.ItemCategoryId  = category7.Id;
                item11.itemCode        = "P004";
                item11.description     = "Pancer Brown(5x7) w/Window";
                item11.stock           = 500;
                item11.measurementUnit = "Each";
                item11.location        = "bin07";
                item11.reorderLevel    = 600;
                item11.reorderQty      = 400;
                item11.price           = 1.1;
                dbcontext.Add(item11);

                Inventory item12 = new Inventory();
                item12.Id              = Guid.NewGuid().ToString();
                item12.ItemCategoryId  = category6.Id;
                item12.itemCode        = "PE004";
                item12.description     = "Pen red";
                item12.stock           = 500;
                item12.measurementUnit = "Each";
                item12.location        = "bin07";
                item12.reorderLevel    = 600;
                item12.reorderQty      = 400;
                item12.price           = 1.1;
                dbcontext.Add(item12);

                Supplier supplier1 = new Supplier();
                supplier1.Id           = Guid.NewGuid().ToString();
                supplier1.supplierCode = "ALPA";
                supplier1.name         = "ALPHA Office Supplies";
                supplier1.address      = "Blk 1128, Ang Mo Kio Industrial Park #02-1108 Ang Mo Kio Street 62 Singapore 622262";
                supplier1.contactNo    = 4619928;
                supplier1.faxNo        = 4612238;
                dbcontext.Add(supplier1);

                Supplier supplier2 = new Supplier();
                supplier2.Id           = Guid.NewGuid().ToString();
                supplier2.supplierCode = "CHEP";
                supplier2.name         = "Cheap Stationer";
                supplier2.address      = "Blk 34, Clementi Road #07-02 Ban Ban Soh Building Singapore 110525";
                supplier2.contactNo    = 3543234;
                supplier2.faxNo        = 4742434;
                dbcontext.Add(supplier2);

                Supplier supplier3 = new Supplier();
                supplier3.Id           = Guid.NewGuid().ToString();
                supplier3.supplierCode = "BANE";
                supplier3.name         = "BANES Shop";
                supplier3.address      = "Blk 124, Alexandra Road #03-04 Banes Building Singapore 550315";
                supplier3.contactNo    = 4781234;
                supplier3.faxNo        = 4792434;
                dbcontext.Add(supplier3);

                Inventory_Supplier inventory_Supplier1 = new Inventory_Supplier();
                inventory_Supplier1.Id = Guid.NewGuid().ToString();
                inventory_Supplier1.InventoryItemId = item1.Id;
                inventory_Supplier1.SupplierId      = supplier1.Id;
                inventory_Supplier1.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier1);

                Inventory_Supplier inventory_Supplier2 = new Inventory_Supplier();
                inventory_Supplier2.Id = Guid.NewGuid().ToString();
                inventory_Supplier2.InventoryItemId = item2.Id;
                inventory_Supplier2.SupplierId      = supplier1.Id;
                inventory_Supplier2.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier2);

                Inventory_Supplier inventory_Supplier3 = new Inventory_Supplier();
                inventory_Supplier3.Id = Guid.NewGuid().ToString();
                inventory_Supplier3.InventoryItemId = item3.Id;
                inventory_Supplier3.SupplierId      = supplier1.Id;
                inventory_Supplier3.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier3);

                Inventory_Supplier inventory_Supplier4 = new Inventory_Supplier();
                inventory_Supplier4.Id = Guid.NewGuid().ToString();
                inventory_Supplier4.InventoryItemId = item4.Id;
                inventory_Supplier4.SupplierId      = supplier1.Id;
                inventory_Supplier4.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier4);

                Inventory_Supplier inventory_Supplier5 = new Inventory_Supplier();
                inventory_Supplier5.Id = Guid.NewGuid().ToString();
                inventory_Supplier5.InventoryItemId = item5.Id;
                inventory_Supplier5.SupplierId      = supplier2.Id;
                inventory_Supplier5.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier5);

                Inventory_Supplier inventory_Supplier6 = new Inventory_Supplier();
                inventory_Supplier6.Id = Guid.NewGuid().ToString();
                inventory_Supplier6.InventoryItemId = item6.Id;
                inventory_Supplier6.SupplierId      = supplier2.Id;
                inventory_Supplier6.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier6);

                Inventory_Supplier inventory_Supplier7 = new Inventory_Supplier();
                inventory_Supplier7.Id = Guid.NewGuid().ToString();
                inventory_Supplier7.InventoryItemId = item7.Id;
                inventory_Supplier7.SupplierId      = supplier2.Id;
                inventory_Supplier7.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier7);

                Inventory_Supplier inventory_Supplier8 = new Inventory_Supplier();
                inventory_Supplier8.Id = Guid.NewGuid().ToString();
                inventory_Supplier8.InventoryItemId = item8.Id;
                inventory_Supplier8.SupplierId      = supplier3.Id;
                inventory_Supplier8.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier8);

                Inventory_Supplier inventory_Supplier9 = new Inventory_Supplier();
                inventory_Supplier9.Id = Guid.NewGuid().ToString();
                inventory_Supplier9.InventoryItemId = item9.Id;
                inventory_Supplier9.SupplierId      = supplier3.Id;
                inventory_Supplier9.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier9);

                Inventory_Supplier inventory_Supplier10 = new Inventory_Supplier();
                inventory_Supplier10.Id = Guid.NewGuid().ToString();
                inventory_Supplier10.InventoryItemId = item10.Id;
                inventory_Supplier10.SupplierId      = supplier3.Id;
                inventory_Supplier10.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier10);


                Inventory_Supplier inventory_Supplier11 = new Inventory_Supplier();
                inventory_Supplier11.Id = Guid.NewGuid().ToString();
                inventory_Supplier11.InventoryItemId = item11.Id;
                inventory_Supplier11.SupplierId      = supplier1.Id;
                inventory_Supplier11.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier11);

                Inventory_Supplier inventory_Supplier12 = new Inventory_Supplier();
                inventory_Supplier12.Id = Guid.NewGuid().ToString();
                inventory_Supplier12.InventoryItemId = item12.Id;
                inventory_Supplier12.SupplierId      = supplier1.Id;
                inventory_Supplier12.qtyOrdered      = 300;
                dbcontext.Add(inventory_Supplier12);

                Departments EN = new Departments();
                EN.Id                = Guid.NewGuid().ToString();
                EN.DeptCode          = "ENGL";
                EN.DeptName          = "English Dept";
                EN.ContactName       = "English";
                EN.FaxNumber         = 123456;
                EN.PhoneNumber       = 112124;
                EN.CollectionPointId = cp1.Id;
                dbcontext.Add(EN);

                Departments CS = new Departments();
                CS.Id                = Guid.NewGuid().ToString();
                CS.DeptCode          = "CPSC";
                CS.DeptName          = "ComputerScience";
                CS.ContactName       = "Computer";
                CS.FaxNumber         = 111111;
                CS.PhoneNumber       = 1165613;
                CS.CollectionPointId = cp3.Id;
                dbcontext.Add(CS);

                Departments Comm = new Departments();
                Comm.Id                = Guid.NewGuid().ToString();
                Comm.DeptCode          = "ENGL";
                Comm.DeptName          = "Commerce Dept";
                Comm.ContactName       = "Commerce";
                Comm.FaxNumber         = 22222;
                Comm.PhoneNumber       = 112164;
                Comm.CollectionPointId = cp2.Id;
                dbcontext.Add(Comm);

                Departments regr = new Departments();
                regr.Id                = Guid.NewGuid().ToString();
                regr.DeptCode          = "Regr";
                regr.DeptName          = "Registra Dept";
                regr.ContactName       = "Registra";
                regr.FaxNumber         = 33333;
                regr.PhoneNumber       = 112231;
                regr.CollectionPointId = cp5.Id;
                dbcontext.Add(regr);

                Departments StationeryDept = new Departments();
                StationeryDept.Id                = Guid.NewGuid().ToString();
                StationeryDept.DeptCode          = "STAT";
                StationeryDept.DeptName          = "Stationery Dept";
                StationeryDept.ContactName       = "Stationery";
                StationeryDept.PhoneNumber       = 69999;
                StationeryDept.FaxNumber         = 4444;
                StationeryDept.CollectionPointId = cp1.Id;
                dbcontext.Add(StationeryDept);

                Employee employee1 = new Employee();
                employee1.Id    = Guid.NewGuid().ToString();
                employee1.Name  = "nhw";
                employee1.Email = "*****@*****.**";
                string emp1psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee1.Password      = emp1psw;
                employee1.Role          = Role.STORE_CLERK;
                employee1.DepartmentsId = StationeryDept.Id;
                dbcontext.Add(employee1);

                Employee employee2 = new Employee();
                employee2.Id    = Guid.NewGuid().ToString();
                employee2.Name  = "wpa";
                employee2.Email = "*****@*****.**";
                string emp2psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee2.Password      = emp2psw;
                employee2.Role          = Role.STORE_SUPERVISOR;
                employee2.DepartmentsId = StationeryDept.Id;
                dbcontext.Add(employee2);

                Employee employee3 = new Employee();
                employee3.Id    = Guid.NewGuid().ToString();
                employee3.Name  = "keith";
                employee3.Email = "*****@*****.**";
                string emp3psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee3.Password      = emp3psw;
                employee3.Role          = Role.STORE_MANAGER;
                employee3.DepartmentsId = StationeryDept.Id;
                dbcontext.Add(employee3);
                StationeryDept.DeptHead       = employee3.Name;
                StationeryDept.Representative = employee2.Name;

                Employee employee4 = new Employee();
                employee4.Id    = Guid.NewGuid().ToString();
                employee4.Name  = "tom";
                employee4.Email = "*****@*****.**";
                string emp4psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee4.Password      = emp4psw;
                employee4.Role          = Role.DEPT_HEAD;
                employee4.DepartmentsId = EN.Id;
                dbcontext.Add(employee4);

                Employee employee5 = new Employee();
                employee5.Id    = Guid.NewGuid().ToString();
                employee5.Name  = "tessa";
                employee5.Email = "*****@*****.**";
                string emp5psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee5.Password      = emp5psw;
                employee5.Role          = Role.DEPT_REP;
                employee5.DepartmentsId = EN.Id;
                dbcontext.Add(employee5);
                EN.Representative = employee5.Name;
                EN.DeptHead       = employee4.Name;

                Employee employee6 = new Employee();
                employee6.Id    = Guid.NewGuid().ToString();
                employee6.Name  = "kk";
                employee6.Email = "*****@*****.**";
                string emp6psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee6.Password      = emp6psw;
                employee6.Role          = Role.EMPLOYEE;
                employee6.DepartmentsId = EN.Id;
                dbcontext.Add(employee6);


                Employee employee7 = new Employee();
                employee7.Id    = Guid.NewGuid().ToString();
                employee7.Name  = "marine1";
                employee7.Email = "*****@*****.**";
                string emp7psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee7.Password      = emp7psw;
                employee7.Role          = Role.DEPT_HEAD;
                employee7.DepartmentsId = CS.Id;
                dbcontext.Add(employee7);

                Employee employee8 = new Employee();
                employee8.Id    = Guid.NewGuid().ToString();
                employee8.Name  = "noah";
                employee8.Email = "*****@*****.**";
                string emp8psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee8.Password      = emp8psw;
                employee8.Role          = Role.DEPT_REP;
                employee8.DepartmentsId = CS.Id;
                dbcontext.Add(employee8);
                CS.DeptHead       = employee7.Name;
                CS.Representative = employee8.Name;

                Employee employee9 = new Employee();
                employee9.Id    = Guid.NewGuid().ToString();
                employee9.Name  = "liam";
                employee9.Email = "*****@*****.**";
                string emp9psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee9.Password      = emp9psw;
                employee9.Role          = Role.EMPLOYEE;
                employee9.DepartmentsId = CS.Id;
                dbcontext.Add(employee9);


                Employee employee10 = new Employee();
                employee10.Id    = Guid.NewGuid().ToString();
                employee10.Name  = "emma";
                employee10.Email = "*****@*****.**";
                string emp10psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee10.Password      = emp10psw;
                employee10.Role          = Role.DEPT_HEAD;
                employee10.DepartmentsId = Comm.Id;
                dbcontext.Add(employee10);

                Employee employee11 = new Employee();
                employee11.Id    = Guid.NewGuid().ToString();
                employee11.Name  = "willian";
                employee11.Email = "*****@*****.**";
                string emp11psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee11.Password      = emp11psw;
                employee11.Role          = Role.DEPT_REP;
                employee11.DepartmentsId = Comm.Id;
                dbcontext.Add(employee11);
                Comm.DeptHead       = employee10.Name;
                Comm.Representative = employee11.Name;

                Employee employee12 = new Employee();
                employee12.Id    = Guid.NewGuid().ToString();
                employee12.Name  = "james";
                employee12.Email = "*****@*****.**";
                string emp12psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee12.Password      = emp12psw;
                employee12.Role          = Role.EMPLOYEE;
                employee12.DepartmentsId = Comm.Id;
                dbcontext.Add(employee12);


                Employee employee13 = new Employee();
                employee13.Id    = Guid.NewGuid().ToString();
                employee13.Name  = "ava";
                employee13.Email = "*****@*****.**";
                string emp13psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee13.Password      = emp13psw;
                employee13.Role          = Role.DEPT_HEAD;
                employee13.DepartmentsId = regr.Id;
                dbcontext.Add(employee13);

                Employee employee14 = new Employee();
                employee14.Id    = Guid.NewGuid().ToString();
                employee14.Name  = "isabella";
                employee14.Email = "*****@*****.**";
                string emp14psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee14.Password      = emp14psw;
                employee14.Role          = Role.DEPT_REP;
                employee14.DepartmentsId = regr.Id;
                dbcontext.Add(employee14);
                regr.DeptHead       = employee13.Name;
                regr.Representative = employee14.Name;

                Employee employee15 = new Employee();
                employee15.Id    = Guid.NewGuid().ToString();
                employee15.Name  = "liam";
                employee15.Email = "*****@*****.**";
                string emp15psw = MD5Hash.GetMd5Hash(md5Hash, "123");
                employee15.Password      = emp15psw;
                employee15.Role          = Role.EMPLOYEE;
                employee15.DepartmentsId = regr.Id;
                dbcontext.Add(employee15);

                PurchaseOrder po1 = new PurchaseOrder();
                po1.Id         = Guid.NewGuid().ToString();
                po1.SupplierId = supplier1.Id;
                po1.EmployeeId = employee1.Id;
                po1.date       = DateTime.Now;
                po1.status     = POStatus.PENDING;
                dbcontext.Add(po1);

                PurchaseOrderDetails po1detail1 = new PurchaseOrderDetails();
                po1detail1.Id = Guid.NewGuid().ToString();
                po1detail1.PurchaseOrderId = po1.Id;
                po1detail1.InventoryId     = item1.Id;
                po1detail1.quantity        = 20;
                dbcontext.Add(po1detail1);

                PurchaseOrderDetails po1detail2 = new PurchaseOrderDetails();
                po1detail2.Id = Guid.NewGuid().ToString();
                po1detail2.PurchaseOrderId = po1.Id;
                po1detail2.InventoryId     = item3.Id;
                po1detail2.quantity        = 20;
                dbcontext.Add(po1detail2);

                PurchaseOrderDetails po1detail3 = new PurchaseOrderDetails();
                po1detail3.Id = Guid.NewGuid().ToString();
                po1detail3.PurchaseOrderId = po1.Id;
                po1detail3.InventoryId     = item4.Id;
                po1detail3.quantity        = 20;
                dbcontext.Add(po1detail3);

                PurchaseOrder po2 = new PurchaseOrder();
                po2.Id         = Guid.NewGuid().ToString();
                po2.SupplierId = supplier2.Id;
                po2.EmployeeId = employee1.Id;
                po2.date       = DateTime.Now.AddMonths(-1);
                po2.status     = POStatus.PENDING;
                dbcontext.Add(po2);

                PurchaseOrderDetails po2detail1 = new PurchaseOrderDetails();
                po2detail1.Id = Guid.NewGuid().ToString();
                po2detail1.PurchaseOrderId = po2.Id;
                po2detail1.InventoryId     = item2.Id;
                po2detail1.quantity        = 20;
                dbcontext.Add(po2detail1);

                PurchaseOrderDetails po2detail2 = new PurchaseOrderDetails();
                po2detail2.Id = Guid.NewGuid().ToString();
                po2detail2.PurchaseOrderId = po2.Id;
                po2detail2.InventoryId     = item7.Id;
                po2detail2.quantity        = 20;
                dbcontext.Add(po2detail2);

                PurchaseOrderDetails po2detail3 = new PurchaseOrderDetails();
                po2detail3.Id = Guid.NewGuid().ToString();
                po2detail3.PurchaseOrderId = po2.Id;
                po2detail3.InventoryId     = item5.Id;
                po2detail3.quantity        = 20;
                dbcontext.Add(po2detail3);

                PurchaseOrderDetails po2detail4 = new PurchaseOrderDetails();
                po2detail4.Id = Guid.NewGuid().ToString();
                po2detail4.PurchaseOrderId = po2.Id;
                po2detail4.InventoryId     = item11.Id;
                po2detail4.quantity        = 10;
                dbcontext.Add(po2detail4);

                PurchaseOrderDetails po2detail5 = new PurchaseOrderDetails();
                po2detail5.Id = Guid.NewGuid().ToString();
                po2detail5.PurchaseOrderId = po2.Id;
                po2detail5.InventoryId     = item12.Id;
                po2detail5.quantity        = 15;
                dbcontext.Add(po2detail5);


                Requisition requisition1 = new Requisition();
                requisition1.Id                 = EN.DeptCode + "_" + DateTime.Now.ToString("MM/dd/yyyy/HH:mm:ss");
                requisition1.DepartmentId       = EN.Id;
                requisition1.EmployeeId         = employee6.Id;
                requisition1.ApprovedEmployeeId = employee4.Id;
                requisition1.DateSubmitted      = DateTime.Now;
                requisition1.status             = ReqStatus.APPROVED;
                requisition1.Remarks            = "nothing";
                dbcontext.Add(requisition1);

                RequisitionDetail requisition1Detail = new RequisitionDetail();
                requisition1Detail.Id             = Guid.NewGuid().ToString();
                requisition1Detail.RequisitionId  = requisition1.Id;
                requisition1Detail.InventoryId    = item1.Id;
                requisition1Detail.RequestedQty   = 20;
                requisition1Detail.DistributedQty = 0;
                dbcontext.Add(requisition1Detail);

                RequisitionDetail requisition1Detail2 = new RequisitionDetail();
                requisition1Detail2.Id             = Guid.NewGuid().ToString();
                requisition1Detail2.RequisitionId  = requisition1.Id;
                requisition1Detail2.InventoryId    = item11.Id;
                requisition1Detail2.RequestedQty   = 20;
                requisition1Detail2.DistributedQty = 0;
                dbcontext.Add(requisition1Detail2);


                RequisitionDetail requisition1Detail3 = new RequisitionDetail();
                requisition1Detail3.Id             = Guid.NewGuid().ToString();
                requisition1Detail3.RequisitionId  = requisition1.Id;
                requisition1Detail3.InventoryId    = item10.Id;
                requisition1Detail3.RequestedQty   = 20;
                requisition1Detail3.DistributedQty = 0;
                dbcontext.Add(requisition1Detail3);

                Requisition requisition2 = new Requisition();
                requisition2.Id                 = CS.DeptCode + "_" + DateTime.Now.ToString("MM/dd/yyyy/HH:mm:ss");
                requisition2.DepartmentId       = CS.Id;
                requisition2.EmployeeId         = employee9.Id;
                requisition2.ApprovedEmployeeId = employee7.Id;
                requisition2.DateSubmitted      = DateTime.Now;
                requisition2.status             = ReqStatus.OUTSTAND;
                requisition2.Remarks            = "nothing";
                dbcontext.Add(requisition2);

                RequisitionDetail requisition2Detail = new RequisitionDetail();
                requisition2Detail.Id             = Guid.NewGuid().ToString();
                requisition2Detail.RequisitionId  = requisition2.Id;
                requisition2Detail.InventoryId    = item2.Id;
                requisition2Detail.RequestedQty   = 20;
                requisition2Detail.DistributedQty = 0;
                dbcontext.Add(requisition2Detail);

                RequisitionDetail requisition2Detail2 = new RequisitionDetail();
                requisition2Detail2.Id             = Guid.NewGuid().ToString();
                requisition2Detail2.RequisitionId  = requisition2.Id;
                requisition2Detail2.InventoryId    = item3.Id;
                requisition2Detail2.RequestedQty   = 20;
                requisition2Detail2.DistributedQty = 0;
                dbcontext.Add(requisition2Detail2);

                //-------------------------------------------------------------Seeding for training model-------------------------------------------------------------------------------------->
                Inventory[] arrInv = new Inventory[] { item1, item2, item3, item4, item5, item6, item7, item8, item9, item10 };

                Random rand = new Random();
                int    size = 10;
                for (int i = 0; i < size; i++)
                {
                    DateTime    randDate     = DateTime.Now.AddDays(-rand.Next(1100));
                    int         randomQty    = rand.Next(1, 100);
                    int         randomStatus = rand.Next(0, 7);
                    Requisition r1           = new Requisition();
                    r1.Id                 = EN.DeptCode + "_" + Guid.NewGuid().ToString();
                    r1.DepartmentId       = EN.Id;
                    r1.EmployeeId         = employee6.Id;
                    r1.ApprovedEmployeeId = employee4.Id;
                    r1.DateSubmitted      = randDate;
                    r1.status             = (ReqStatus)randomStatus;
                    r1.Remarks            = "nothing";
                    List <string>            list   = new List <string>();
                    List <RequisitionDetail> rLists = new List <RequisitionDetail>();
                    for (int j = 0; j < 3; j++)
                    {
                        RequisitionDetail rd1 = new RequisitionDetail();
                        rd1.Id = Guid.NewGuid().ToString();
                        int    randomItem = rand.Next(arrInv.Length);
                        string item       = arrInv[randomItem].Id;
                        while (list.FirstOrDefault(x => x.Contains(item)) != null)
                        {
                            randomItem = rand.Next(arrInv.Length);
                            item       = arrInv[randomItem].Id;
                        }
                        rd1.RequisitionId = r1.Id;
                        rd1.Inventory     = arrInv[randomItem];
                        //rd1.InventoryId = item;
                        rd1.RequestedQty   = randomQty;
                        rd1.DistributedQty = 0;
                        list.Add(arrInv[randomItem].Id);
                        rLists.Add(rd1);
                    }
                    list.Clear();
                    dbcontext.AddRangeAsync(rLists);
                    dbcontext.Add(r1);

                    int           randomPOStatus = rand.Next(0, 2);
                    PurchaseOrder po11           = new PurchaseOrder();
                    po11.Id         = Guid.NewGuid().ToString();
                    po11.SupplierId = supplier1.Id;
                    po11.EmployeeId = employee1.Id;
                    po11.date       = randDate;
                    po11.status     = (POStatus)randomPOStatus;
                    dbcontext.Add(po11);
                    for (int k = 0; k < 5; k++)
                    {
                        int randomI = rand.Next(arrInv.Length);
                        PurchaseOrderDetails pod1 = new PurchaseOrderDetails();
                        pod1.Id = Guid.NewGuid().ToString();
                        pod1.PurchaseOrderId = po11.Id;
                        pod1.InventoryId     = arrInv[randomI].Id;
                        pod1.quantity        = randomQty;
                        dbcontext.Add(pod1);
                    }
                }

                //-------------------------------------------------------------Seeding for training model-------------------------------------------------------------------------------------->

                Requisition requisition3 = new Requisition();
                requisition3.Id                 = regr.DeptCode + "_" + DateTime.Now.ToString("MM/dd/yyyy/HH:mm:ss");
                requisition3.DepartmentId       = regr.Id;
                requisition3.EmployeeId         = employee15.Id;
                requisition3.ApprovedEmployeeId = employee13.Id;
                requisition3.DateSubmitted      = DateTime.Now;
                requisition3.status             = ReqStatus.REJECTED;
                requisition3.Remarks            = "nothing";
                dbcontext.Add(requisition3);

                Requisition requisition4 = new Requisition();
                requisition4.Id                 = regr.DeptCode + "/" + DateTime.Now;
                requisition4.DepartmentId       = regr.Id;
                requisition4.EmployeeId         = employee15.Id;
                requisition4.ApprovedEmployeeId = employee13.Id;
                requisition4.DateSubmitted      = DateTime.Now;
                requisition4.status             = ReqStatus.PROCESSING;
                requisition4.Remarks            = "nothing";
                dbcontext.Add(requisition4);

                AdjustmentVoucher vouncher = new AdjustmentVoucher();
                vouncher.Id              = Guid.NewGuid().ToString();
                vouncher.EmEmployeeId    = employee1.Id;
                vouncher.appEmEmployeeId = employee2.Id;
                vouncher.InventoryId     = item1.Id;
                vouncher.status          = Status.PENDING;
                vouncher.qty             = -5;
                vouncher.reason          = "missing";
                dbcontext.Add(vouncher);
                Disbursement d1 = new Disbursement()
                {
                    Id             = Guid.NewGuid().ToString(),
                    GeneratedDate  = DateTime.Now,
                    CollectionDate = DateTime.Now,
                    status         = DisbusementStatus.DELIVERED,
                    storeClerk     = employee1,
                    Departments    = EN
                };
                dbcontext.Add(d1);
                DisbursementDetail d1detail1 = new DisbursementDetail();
                d1detail1.Id                      = Guid.NewGuid().ToString();
                d1detail1.DisbursementId          = d1.Id;
                d1detail1.RequisitionDetailId     = requisition1Detail.Id;
                d1detail1.disbursedQty            = 20;
                requisition1Detail.DistributedQty = 20;
                dbcontext.Add(d1detail1);
                Disbursement d4 = new Disbursement()
                {
                    Id             = Guid.NewGuid().ToString(),
                    GeneratedDate  = DateTime.Now,
                    CollectionDate = DateTime.Now,
                    storeClerk     = employee1,
                    status         = DisbusementStatus.COMPLETED,
                    Departments    = EN
                };
                dbcontext.Add(d4);
                DisbursementDetail d4detail1 = new DisbursementDetail();
                d4detail1.Id                      = Guid.NewGuid().ToString();
                d4detail1.DisbursementId          = d4.Id;
                d4detail1.RequisitionDetailId     = requisition2Detail.Id;
                d4detail1.disbursedQty            = 20;
                requisition2Detail.DistributedQty = 20;
                dbcontext.Add(d4detail1);
                dbcontext.SaveChanges();
            }
        }
Ejemplo n.º 21
0
        public void DeleteCollectionPoint(string collectionId)
        {
            CollectionPoint collectionPoint = context.CollectionPoints.Find(collectionId);

            context.CollectionPoints.Remove(collectionPoint);
        }
Ejemplo n.º 22
0
 public CollectionPointPayload(CollectionPoint cp)
 {
     CollectionPointID      = cp.CollectionPointID;
     CollectionPointDetails = cp.CollectionPointDetails;
 }
Ejemplo n.º 23
0
 public void UpdateCollectionPoint(CollectionPoint collectionPoint)
 {
     context.Entry(collectionPoint).State = EntityState.Modified;
 }
 public void UpdateCollectionPoint(CollectionPoint collectionPoint)
 {
     CollectionPointRepo.Instance.Update(collectionPoint);
 }
        public JsonResult PostRetrieval(Retrieval Details)
        {
            List <RetrievalItem> cc = JsonConvert.DeserializeObject <List <RetrievalItem> >(Details.RetData[0]);

            if (ModelState.IsValid)
            {
                List <string> departmentList       = new List <string>();
                int           outstandingListCount = db.OutstandingLists.Count();

                //update retrieval form status to "Submitted"
                StationeryRetrievalForm existingStationeryRetrievalForm = db.StationeryRetrievalForms.Find(cc[0].FormNumber);
                existingStationeryRetrievalForm.Status = "Submitted";

                foreach (RetrievalItem commitedFormDetail in cc)
                {
                    //Update actual values into retrieval form details
                    StationeryRetrievalFormDetail existingStationeryRetrievalFormDetail = db.StationeryRetrievalFormDetails.Find(commitedFormDetail.FormDetailsnumber);
                    existingStationeryRetrievalFormDetail.Actual = Convert.ToInt32(commitedFormDetail.Actual);

                    //update stationery catalog
                    StationeryCatalog existingCatalog = db.StationeryCatalogs.Find(commitedFormDetail.ItemNumber);
                    existingCatalog.Balance -= Convert.ToInt32(commitedFormDetail.Actual);

                    //add the department code to our department list created above, to generate disbursement list by department below
                    if (!departmentList.Contains(commitedFormDetail.Dept))
                    {
                        departmentList.Add(commitedFormDetail.Dept);
                    }

                    //If insufficient inventory, add the item code to our item code list created above, so that we can generate a Outstanding List by item code
                    if (Convert.ToInt32(commitedFormDetail.Needed) > Convert.ToInt32(commitedFormDetail.Actual))
                    {
                        outstandingListCount++;

                        OutstandingList outstandingItem = new OutstandingList
                        {
                            OutstandingListNumber      = outstandingListCount.ToString(),
                            RetrievalFormDetailsNumber = commitedFormDetail.FormDetailsnumber,
                            Status = "Outstanding"
                        };
                        db.OutstandingLists.Add(outstandingItem);
                    }

                    db.SaveChanges();
                }

                //create a single disbursement list for each department
                foreach (string deptCode in departmentList)
                {
                    DisbursementList dl = new DisbursementList
                    {
                        ListNumber     = (db.DisbursementLists.Count() + 1).ToString(),
                        DepartmentCode = deptCode,
                        Date           = DateTime.Today,
                        Status         = "Pending"
                    };
                    db.DisbursementLists.Add(dl);
                    db.SaveChanges();

                    DepartmentList  dept         = db.DepartmentLists.Where(x => x.DepartmentCode == deptCode).FirstOrDefault();
                    string          Eid          = dept.RepresentativeId;
                    Employee        repo         = db.Employees.Find(Eid);
                    string          emailAddress = repo.EmailAddress;
                    string          pointId      = dept.CollectionPoint;
                    CollectionPoint point        = db.CollectionPoints.Find(pointId);
                    string          subject      = "Your items are ready for collection";
                    string          message      = "<p>Dear " + repo.UserName + "." + "</p><br/><p>Your items are ready for collection</p><br/><p>Collection point and time: " + point.CollectionPointName + "---" + point.CollectionTime + "</p><br/><p>Stationery Management Team</p>";
                    util.SendEmail(emailAddress, subject, message);

                    int disbursementListDetailsCount = db.DisbursementListDetails.Count();

                    foreach (RetrievalItem commitedFormDetail in cc)
                    {
                        if (commitedFormDetail.Dept.Equals(deptCode))
                        {
                            disbursementListDetailsCount++;

                            DisbursementListDetail dld = new DisbursementListDetail
                            {
                                ListDetailsNumber = disbursementListDetailsCount.ToString(),
                                ListNumber        = dl.ListNumber,
                                ItemNumber        = commitedFormDetail.ItemNumber,
                                Quantity          = Convert.ToInt32(commitedFormDetail.Actual)
                            };

                            db.DisbursementListDetails.Add(dld);
                            db.SaveChanges();
                        }
                    }
                }
            }
            return(Json(new { status = "success" }));
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> changeCollectionPoint([Bind("DeptId,Name,DeptRep,Cpid")] Department department, CollectionPoint collectionPoint)
        {
            MyUser user = _context.MyUser.Where(p => p.Email == HttpContext.User.Identity.Name).ToList().FirstOrDefault();
            int?   id   = user.DeptId;

            if (id != department.DeptId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.DeptId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                List <MyUser> allclerks = new List <MyUser>();
                allclerks = _context.MyUser.Where(x => x.RoleId == 5).ToList();
                CollectionPoint cp = new CollectionPoint();
                cp = _context.CollectionPoint.Where(x => x.Cpid == collectionPoint.Cpid).FirstOrDefault();

                #region Email
                var message = new MimeMessage();
                message.From.Add(new MailboxAddress("SSIS", "*****@*****.**"));
                //message.To.Add(new MailboxAddress("tqy", "*****@*****.**"));
                message.Subject = "New collection point";
                foreach (MyUser clerk in allclerks)
                {
                    message.To.Add(new MailboxAddress(clerk.Name, clerk.Email));

                    message.Body = new TextPart("plain")
                    {
                        Text = "Dear " + clerk.Name + ", " +
                               "This letter is to let you know we have selected the collection point " +
                               "and delivery timing as " + cp.Name + "." +
                               "Please check and find details of the location below:" +
                               Environment.NewLine +
                               cp.Details +
                               Environment.NewLine +
                               "Regards" +
                               Environment.NewLine +
                               department.Name +
                               " department"
                    };
                }
                using (var client = new SmtpClient())
                {
                    client.Connect("smtp.gmail.com", 587, false);
                    client.Authenticate("*****@*****.**", "team2team2");
                    client.Send(message);
                    client.Disconnect(true);
                }
                #endregion
                return(RedirectToAction("About", "Home"));
            }
            return(View());
        }
    public WCF_CollectionPoint getCollectionListbyDept(string DeptID)
    {
        CollectionPoint collection_point = CollectionManager_M.getCollectionInfoByDepID(DeptID);

        return(new WCF_CollectionPoint(collection_point.Collection_ID, collection_point.Collection_Desc));
    }
Ejemplo n.º 28
0
 public void Close()
 {
     gameObject.SetActive(false);
     collectionPoint = null;
 }