public async Task <ActionResult <List <CartItemDto> > > Cart() { var user = _helper.GetCurrentUserEmail(); var result = await _cartService.UserCartItems(user); return(Ok(result)); }
public async Task <IServiceResponse <bool> > SendOtp() { var otp = Guid.NewGuid().ToString().Remove(8).ToUpper(); return(await HandleApiOperationAsync(async() => { var email = await _userManagerSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); var operationManager = await _empSvc.GetOperationManager(email.Email); if (operationManager.Email != null) { await _empSvc.UpdateEmployeeOtp(operationManager.Id, otp); string smsMessage = ""; smsMessage = $"A ticket discount has been requested from your terminal by " + _serviceHelper.GetCurrentUserEmail() + ". Kindly use " + otp + " as your One Time Password"; try { _smsSvc.SendSMSNow(smsMessage, recipient: operationManager.PhoneNumber.ToNigeriaMobile()); var mail = new Mail(appConfig.AppEmail, "Urgent: Ticket Discount!", operationManager.Email) { Body = "A ticket discount has been requested from your terminal by " + _serviceHelper.GetCurrentUserEmail() + ". Kindly use " + otp + " as your One Time Password\r\n\r\nSent from Transport" }; _mailSvc.SendMail(mail); } catch { //Console.WriteLine("Error reading from {0}. Message = {1}", path, e.Message); } } return new ServiceResponse <bool>(true); })); }
public async Task <List <VehicleDTO> > GetAvailableVehiclesInTerminal() { var employeeTerminal = await(from employee in _employeeRepo.GetAllIncluding(x => x.User) join terminal in _terminalRepo.GetAll() on employee.TerminalId equals terminal.Id where employee.User.UserName == _serviceHelper.GetCurrentUserEmail() select terminal).FirstOrDefaultAsync(); return(employeeTerminal is null ? new List <VehicleDTO>() : await GetAvailableVehiclesInTerminal(employeeTerminal.Id)); }
public async Task <IServiceResponse <EmployeeDTO> > GetEmployeeByMail() { return(await HandleApiOperationAsync(async() => { var email = await _userManagerSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); var employee = await _employeeSvc.GetEmployeesByemailAsync(email.Email); return new ServiceResponse <EmployeeDTO> { Object = employee }; })); }
public async Task ApproveJourney(Guid journeyManagementId) { var journey = _repo.Get(journeyManagementId); journey.JourneyStatus = JourneyStatus.InTransit; journey.ApprovedBy = _serviceHelper.GetCurrentUserEmail() ?? "Anon"; journey.LastModificationTime = DateTime.Now; await _repo.UpdateAsync(journey); await _uow.SaveChangesAsync(); }
public async Task <ActionResult> CreateOrder(OrderDto order) { order.Email = _helper.GetCurrentUserEmail(); await _orderService.CreateOrder(order); return(Ok()); }
public async Task <IServiceResponse <List <JourneyDto> > > JourneysIncoming(JourneyQueryDto queryDto) { return(await HandleApiOperationAsync(async() => { var employee = _serviceHelper.GetCurrentUserEmail(); queryDto.TerminalId = await _employeeService.GetAssignedTerminal(employee) ?? throw new Exception("Invalid user access"); //queryDto.StartDate = new DateTime(2019, 1, 2); queryDto.StartDate = queryDto.StartDate ?? DateTime.Now.Date; queryDto.EndDate = queryDto.EndDate ?? DateTime.Now; var journeys = await _journeyService.GetIncomingJournies(queryDto.TerminalId.Value, queryDto.StartDate, queryDto.EndDate); return new ServiceResponse <List <JourneyDto> > { Object = journeys }; })); }
public async Task <IServiceResponse <List <RouteDTO> > > GetStaffTerminalRoutes() { var email = await _userManagerSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); return(await HandleApiOperationAsync(async() => { var ticketerRoutes = await _routeSvc.GetStaffTerminalRoutes(email.Email); return new ServiceResponse <List <RouteDTO> > { Object = ticketerRoutes }; })); }
public async Task <bool> Verifyotp(string otp) { var email = await _userSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); var operationManager = await GetOperationManager(email.Email); if (operationManager.Otp == otp && !operationManager.OtpIsUsed) { await UpdateUsedEmployeeOtp(operationManager.Id); return(true); } return(false); }
public async Task AddManifest(ManifestDTO manifest) { var existingManifestManagement = await GetManifestManagementsByVehicleTripIdAsync(manifest.VehicleTripRegistrationId); var vehicleTripReg = await _vehicleTripRepo.GetAsync(manifest.VehicleTripRegistrationId); if (existingManifestManagement != null) { existingManifestManagement.IsPrinted = manifest.IsPrinted; existingManifestManagement.ManifestPrinted = manifest.ManifestPrinted; await UpdateManifestManagement(existingManifestManagement.Id, existingManifestManagement); } else { var listOfSeat = await _seatManagemengtSvc.GetByVehicleTripIdAsync( manifest.VehicleTripRegistrationId); var fare = await GetTripFare(manifest.VehicleTripRegistrationId); decimal?amount = fare?.Amount; _repository.Insert(new Manifest { NumberOfSeats = listOfSeat.Count, Employee = _serviceHelper.GetCurrentUserEmail(), VehicleTripRegistrationId = manifest.VehicleTripRegistrationId, Amount = amount, VehicleModelId = vehicleTripReg.VehicleModelId }); await _unitOfWork.SaveChangesAsync(); } }
private void AddEntry(Guid vehicleTripRegistrationId, string refcode, decimal amount, TransactionType transType = TransactionType.Credit) { var transEntry = new AccountTransaction { Id = SequentialGuidGenerator.Instance.Create(), AccountType = AccountType.BookingAccount, LastModificationTime = Clock.Now, CreatorUserId = _serviceHelper.GetCurrentUserId(), TransactionDate = Clock.Now, TransactionSourceId = vehicleTripRegistrationId, Narration = refcode }; var summary = new AccountSummary { Id = SequentialGuidGenerator.Instance.Create(), AccountName = _serviceHelper.GetCurrentUserEmail() }; switch (transType) { case TransactionType.Credit: transEntry.TransactionType = transType; transEntry.Amount = Convert.ToDouble(amount); summary.Balance = Convert.ToDouble(amount); break; case TransactionType.Debit: transEntry.TransactionType = transType; transEntry.Amount = -Convert.ToDouble(amount); summary.Balance = -Convert.ToDouble(amount); break; } _repo.Insert(transEntry); _AccountSummarySvc.CreateOrUpdateEntry(summary); }
public async Task <List <RouteDTO> > GetLoginEmployeeRoutes() { var email = await _userSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); var employeeterminalId = await _employeeSvc.GetAssignedTerminal(email.Email); //Context.Employees.FirstOrDefault(x => x.Email == username); var employeeroutes = from route in GetAll() where route.DepartureTerminalId == employeeterminalId select new RouteDTO { Name = route.Name, Id = route.Id, RouteType = route.Type, AvailableOnline = route.AvailableOnline, AvailableAtTerminal = route.AvailableAtTerminal }; return(employeeroutes.AsNoTracking().ToList()); }
public async Task CreatePhysicalBus(TerminalBookingDTO physicalbus) { var trip = await _tripSvc.GetTripById(physicalbus.TripId); var vehicle = await _vehicleSvc.GetVehicleById(physicalbus.VehicleId); DateTime departuredate = Clock.Now.Date; var asignedVehicleDto = await _vehicleSvc.GetVehiclesByRegNum(vehicle.RegistrationNumber); if (asignedVehicleDto == null) { throw await _serviceHelper.GetExceptionAsync(ErrorConstants.VEHICLE_NOT_EXIST); } var assignedVehicle = await _vehicleSvc.GetVehicleById(physicalbus.VehicleId); var email = await _userManagerSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail()); var employee = await _employeeSvc.GetEmployeesByemailAsync(email.Email); if (employee != null && employee.TerminalId != null && assignedVehicle.VehicleStatus != VehicleStatus.InWorkshop) { assignedVehicle.LocationId = employee.TerminalId; } //assignedVehicle.Location = null; if (assignedVehicle != null && assignedVehicle.VehicleStatus != VehicleStatus.InWorkshop) { assignedVehicle.VehicleStatus = VehicleStatus.TerminalUse; } if (assignedVehicle != null && assignedVehicle.VehicleStatus == VehicleStatus.InWorkshop) { assignedVehicle.VehicleStatus = VehicleStatus.InWorkshopAndAssigned; } //Get assigned Captain and Update var assignedCaptainDto = await _driverSvc.GetActiveDriverByCodeAsync(physicalbus.DriverCode); if (assignedCaptainDto == null) { throw await _serviceHelper.GetExceptionAsync(ErrorConstants.DRIVER_NOT_EXIST); } var assignedDrv = await _driverSvc.GetAsync(assignedCaptainDto.Id); var phyBus = new VehicleTripRegistration { PhysicalBusRegistrationNumber = vehicle.RegistrationNumber, DepartureDate = departuredate, TripId = physicalbus.TripId, DriverCode = physicalbus.DriverCode, VehicleModelId = trip.VehicleModelId, IsVirtualBus = false, JourneyType = JourneyType.Loaded }; if (assignedDrv.DriverType == DriverType.Virtual) { if (string.IsNullOrEmpty(physicalbus.OriginalDriverCode)) { throw new LMEGenericException("Could not create vehicle because you did not choose the original captain that will take the trip"); } phyBus.OriginalDriverCode = physicalbus.OriginalDriverCode; } else { phyBus.OriginalDriverCode = ""; } _repo.Insert(phyBus); await _unitOfWork.SaveChangesAsync(); }