public void NotifyDeptHeadToApprovePendingRequisition(Requisition newRequisition) { Employee e = employeeRepo.FindById(newRequisition.EmployeeId); string employeeEmail = employeeRepo.FindById(newRequisition.EmployeeId).Email; Employee deptHead = null; string deptHeadEmail = null; Employee cs = employeeRepo.GetCoverStaffByDepartmentIdAndDate(e.DepartmentId, DateTime.Now); if (cs != null) { deptHead = cs; deptHeadEmail = cs.Email; } else { deptHead = employeeRepo.FindOneBy(x => x.DepartmentId == e.DepartmentId && x.RoleId == 1); deptHeadEmail = deptHead.Email; } //MailMessage mail = new MailMessage(employeeEmail, deptHeadEmail); string subject = "New Requisition Form Submission for Approval"; string body = "Dear " + deptHead.Name + ",\n\nPlease review a new Requisition form (Id:" + newRequisition.Id + ") submmission by " + e.Name + " for approval. \n\nThank you and have a great day."; SendNotificationEmail(deptHeadEmail, subject, body); }
public List <Requisition> GetDepartmentRequisitions(int deptHeadEmployeeId) { //get dept Id Employee deptHead = employeeRepo.FindById(deptHeadEmployeeId); return(requisitionRepo.DepartmentRequisitionsEagerLoadEmployee(deptHead.DepartmentId)); }
public ActionResult Index() { //for testing Employee e = employeeRepo.FindById(2); Requisition r = reqRepo.FindById(25); return(View()); }
public Session GetExistingSessionFromGUID(string GUID) { Session s = sessionRepo.FindOneBy(x => x.GUID.Equals(GUID)); // AND ALSO if logouttime == null right?? if (s != null) { Employee e = employeeRepo.FindById(s.EmployeeId); s.Employee = e; } return(s); }
RequisitionDetailsDTO IRequisitionCatalogueService.GetRequisitionDetailsForSingleRequisition(int requisitionId, int employeeId) { string employeeName = employeeRepo.FindById(employeeId).Name; Requisition requisition = requisitionRepo.FindById(requisitionId); List <RequisitionDetail> requisitionDetails = requisitionDetailRepo.RequisitionDetailsEagerLoadStationery(requisitionId); return(new RequisitionDetailsDTO() { EmployeeName = employeeName, RequestedDate = requisition.DateTime.ToString("yyyy-MM-dd"), RequisitionFormId = requisition.Id, RequisitionStatus = requisition.Status, Remarks = requisition.Remarks, RequisitionDetails = requisitionDetails, Requisition = requisition, }); }
public List <Department> retrieveAllDepartmentsWithApprovedRequisitions() { List <Department> departmentList = (List <Department>)departmentRepo.FindAll(); List <Employee> employeesAllDepartments = RetrieveAllEmployeesInAssignedDepartmentList(departmentList); List <Requisition> approvedRequisitionsFromEmployeesInAssignedDepartments = RetrieveAllApprovedRequisitionsByEmployeeList(employeesAllDepartments); List <Employee> distinctEmployeeId = new List <Employee>(); foreach (Requisition req in approvedRequisitionsFromEmployeesInAssignedDepartments.GroupBy(x => x.EmployeeId).Select(g => g.First()).Distinct().ToList()) { Employee outputEmployee = employeeRepo.FindById(req.EmployeeId); distinctEmployeeId.Add(outputEmployee); } List <Department> distinctDepartmentList = new List <Department>(); foreach (Employee x in distinctEmployeeId.GroupBy(x => x.DepartmentId).Select(g => g.First()).Distinct().ToList()) { Department outputDepartment = departmentRepo.FindById(x.DepartmentId); distinctDepartmentList.Add(outputDepartment); } return(distinctDepartmentList); }
public StockAndSupplierDTO RetrieveStockMovement(int stationeryId) { List <StockMovementDTO> stockMovement = new List <StockMovementDTO>(); List <StockMovementBalanceDTO> stockMovementBalance = new List <StockMovementBalanceDTO>(); List <SupplierStockRankDTO> supplierStockRank = new List <SupplierStockRankDTO>(); Stationery s = stationeryRepo.FindById(stationeryId); Category c = categoryRepo.FindById(s.CategoryId); List <SupplierTender> st = (List <SupplierTender>)supplierTenderRepo.FindBy(x => x.StationeryId == stationeryId); List <Supplier> sp = new List <Supplier>(); foreach (SupplierTender rankedsupplier in st) { Supplier supplier = (Supplier)supplierRepo.FindById(rankedsupplier.SupplierId); sp.Add(supplier); } //add Suppliers To SupplierStockRankDTO int limit = 3; for (int i = 1; i <= limit; i++) { SupplierStockRankDTO supstockrank = new SupplierStockRankDTO(); { supstockrank.Rank = i; SupplierTender rankingsupplier = (SupplierTender)supplierTenderRepo.FindOneBy(x => x.StationeryId == stationeryId && x.Rank == i); supstockrank.SupplierCode = rankingsupplier.Supplier.Code; supstockrank.SupplierName = rankingsupplier.Supplier.Name; supstockrank.ContactPerson = rankingsupplier.Supplier.ContactName; supstockrank.ContactNumber = rankingsupplier.Supplier.PhoneNo; supstockrank.Price = rankingsupplier.Price; } supplierStockRank.Add(supstockrank); } //retrieve all adjustment voucher Ids that are acknowledged List <int> avId = adjustmentVoucherRepo.getAdjustmentVoucherIdsWithAcknowledgedStatus(); //retrieve all adjustment voucher details with adjustment voucher Ids that are acknowledged and stationeryId List <AdjustmentVoucherDetail> avDet = new List <AdjustmentVoucherDetail>(); foreach (int adjvouch in avId) { List <AdjustmentVoucherDetail> adjvouchDetail = (List <AdjustmentVoucherDetail>)adjustmentVoucherDetailRepo.FindBy(x => x.AdjustmentVoucherId == adjvouch && x.StationeryId == stationeryId); foreach (AdjustmentVoucherDetail aVD in adjvouchDetail) { avDet.Add(aVD); } } // set retrieved adjustmentvouchers into StockMovementDTO foreach (AdjustmentVoucherDetail adjV in avDet) { StockMovementDTO stockMovList = new StockMovementDTO(); { stockMovList.MovementDate = adjV.DateTime; stockMovList.DepartmentOrSupplier = "Adjustment Voucher - " + adjV.AdjustmentVoucherId; stockMovList.Quantity = adjV.Quantity; } stockMovement.Add(stockMovList); } //retrieve all purchase Order Ids that are closed List <int> poId = purchaseOrderRepo.getPurchaseOrderIdsWithClosedStatus(); //retrieve all PO details with PO Ids that are closed and stationeryId List <PurchaseOrderDetail> purchaseOrderDet = new List <PurchaseOrderDetail>(); foreach (int a in poId) { PurchaseOrderDetail purOrderDetail = (PurchaseOrderDetail)purchaseOrderDetailRepo.FindOneBy(x => x.PurchaseOrderId == a && x.StationeryId == stationeryId); purchaseOrderDet.Add(purOrderDetail); } // set retrieved PODetails into StockMovementDTO foreach (PurchaseOrderDetail poDetail in purchaseOrderDet) { if (poDetail != null) { StockMovementDTO stockMovList = new StockMovementDTO(); { stockMovList.MovementDate = (DateTime)purchaseOrderRepo.FindById(poDetail.PurchaseOrderId).DeliveryDateTime; stockMovList.DepartmentOrSupplier = "Supplier - " + supplierRepo.FindById(purchaseOrderRepo.FindById(poDetail.PurchaseOrderId).SupplierId).Name; stockMovList.Quantity = (int)poDetail.QuantityDelivered; } stockMovement.Add(stockMovList); } } //retrieve all requisitiondetails that are delivered and are of the input stationeryId List <RequisitionDetail> reqDet = (List <RequisitionDetail>)requisitionDetailRepo.FindBy(x => x.Status == "Collected" && x.StationeryId == stationeryId); // set retrieved PODetails into StockMovementDTO foreach (RequisitionDetail reqDetails in reqDet) { StockMovementDTO stockMovList = new StockMovementDTO(); stockMovList.MovementDate = (DateTime)reqDetails.Disbursement.DeliveryDateTime; int rcdEmployeeId = (int)disbursementRepo.FindOneBy(x => x.Id == reqDetails.DisbursementId).ReceivedEmployeeId; stockMovList.DepartmentOrSupplier = employeeRepo.FindById(rcdEmployeeId).Department.DepartmentName;; stockMovList.Quantity = (int)reqDetails.QuantityDelivered * -1; stockMovement.Add(stockMovList); } // order the list by date & alphabetically stockMovement = stockMovement.OrderBy(x => x.MovementDate).ToList(); int runningBal = 0; // set StockMovementDTO into StockMovementBalanceDTO foreach (StockMovementDTO stkMovDTO in stockMovement) { StockMovementBalanceDTO stockMovBalList = new StockMovementBalanceDTO(); stockMovBalList.StockMovement = stkMovDTO; runningBal = runningBal + stkMovDTO.Quantity; stockMovBalList.Balance = runningBal; stockMovementBalance.Add(stockMovBalList); } stockMovement.Reverse(); //stockMovementBalance.Reverse(); // set StockMovementBalanceDTO into StockAndSupplierDTO StockAndSupplierDTO stockAndSuppliers = new StockAndSupplierDTO(); stockAndSuppliers.StationeryId = s.Id; stockAndSuppliers.ItemNumber = s.Code; stockAndSuppliers.Category = (String)categoryRepo.getCategoryType(s.CategoryId); stockAndSuppliers.Description = s.Description; stockAndSuppliers.Location = s.Bin; stockAndSuppliers.UnitOfMeasure = s.UnitOfMeasure; stockAndSuppliers.SupplierStockRank = supplierStockRank; foreach (StockMovementBalanceDTO stockMovementBalanceDTO in stockMovementBalance) { stockMovementBalanceDTO.Balance += s.Quantity - stockMovementBalance.Last().Balance; } stockAndSuppliers.StockMovementBalance = stockMovementBalance; return(stockAndSuppliers); }