public async Task <ResponseViewModel <SystemFunctionViewModel> > GetUserPermission(int userID) { ResponseViewModel <SystemFunctionViewModel> response = new ResponseViewModel <SystemFunctionViewModel>(); Dictionary <string, SystemFunctionViewModel> systemFunctionViewModels = new Dictionary <string, SystemFunctionViewModel>(); var user = await _userRepository.GetAsync(us => us.ID == userID, QueryIncludes.USERFULLINCLUDES); if (user == null) { return(response = ResponseConstructor <SystemFunctionViewModel> .ConstructData(ResponseCode.ERR_USER_NOT_EXSIT, null)); } else { var employee = user.employees.FirstOrDefault(); foreach (var group in employee.groupMaps) { foreach (var function in group.employeeGroup.functionMaps) { try { systemFunctionViewModels.Add(function.systemFunction.Code, Mapper.Map <SystemFunction, SystemFunctionViewModel>(function.systemFunction)); } catch (Exception) { continue; } } } response = ResponseConstructor <SystemFunctionViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, systemFunctionViewModels.Values.ToList()); } return(response); }
public async Task <ResponseViewModel <QueueListViewModel> > GetQueueList() { ResponseViewModel <QueueListViewModel> response = new ResponseViewModel <QueueListViewModel>(); try { var queueList = await _queueListRepository.GetManyAsync(qu => qu.isDelete == false, QueryIncludes.QUEUELISTFULLINCLUDES); if (queueList == null) { response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.ERR_QUE_NO_QUEUE_FOUND, null); } else { response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queueList)); } return(response); } catch (Exception) { return(response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.ERR_QUE_NO_QUEUE_FOUND, null)); } }
public async Task <ResponseViewModel <LaneMgntViewModel> > GetLaneForWarehouseManagement(string code) { ResponseViewModel <LaneMgntViewModel> responseViewModel = new ResponseViewModel <LaneMgntViewModel>(); List <LaneMgntViewModel> laneMgntViewModels = new List <LaneMgntViewModel>(); var lanes = await _laneRepository.GetManyAsync(ln => ln.loadingBay.code.Equals(code) && ln.isDelete == false, QueryIncludes.LANEFULLINCLUDES); foreach (var lane in lanes) { LaneMgntViewModel laneMgntViewModel = new LaneMgntViewModel(); laneMgntViewModel.ID = lane.ID; laneMgntViewModel.LaneName = lane.nameVi; if (lane.usingStatus == LaneStatus.OCCUPIED) { laneMgntViewModel.usingStatus = "Ocuppied"; } else { laneMgntViewModel.usingStatus = "Free"; } laneMgntViewModel.status = lane.status; laneMgntViewModel.truckType = lane.truckType.description; var queue = await _queueListRepository.GetAsync(qu => qu.laneID == lane.ID && qu.gatePass.isDelete == false && qu.gatePass.stateID == GatepassState.STATE_IN_WAREHOUSE_CHECK_IN, QueryIncludes.QUEUELISTFULLINCLUDES); if (queue != null) { var gatePass = await _gatePassRepository.GetAsync(gt => gt.ID == queue.gatePass.ID, QueryIncludes.GATEPASSFULLINCLUDES); // await _gatePassRepository.GetAsync(gt => gt.queueLists.ToArray()[0].laneID == lane.ID && gt.isDelete == false);// && gt.stateID == GatepassState.STATE_FINISH_WAREHOUSE_CHECK_IN); var start = (DateTime)gatePass.enterTime; var end = (DateTime)gatePass.leaveTime; end = end.AddMonths(1); var now = DateTime.Now.Ticks; var percent = ((now - start.Ticks) / (end.Ticks - start.Ticks)) * 100; if (percent < (1 / 4)) { laneMgntViewModel.progress = "0 %"; } else if (percent > (1 / 4) && percent < (1 / 2)) { laneMgntViewModel.progress = "50 %"; } else if (percent > (1 / 2) && percent < 1) { laneMgntViewModel.progress = "75 %"; } else { laneMgntViewModel.progress = "75 %"; } laneMgntViewModel.KPI = gatePass.truck.KPI; laneMgntViewModel.inTime = (DateTime)gatePass.enterTime; laneMgntViewModel.outTime = (DateTime)gatePass.leaveTime; laneMgntViewModel.plateNumber = gatePass.truck.plateNumber; } laneMgntViewModels.Add(laneMgntViewModel); } responseViewModel = ResponseConstructor <LaneMgntViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, laneMgntViewModels); return(responseViewModel); }
public async Task <ResponseViewModel <WeightRecordViewModel> > GetWeightValueByGatePassID(int gatePassID) { ResponseViewModel <WeightRecordViewModel> response = new ResponseViewModel <WeightRecordViewModel>(); try { var weighRecord = await _weightRecordRepository.GetManyAsync(wt => wt.gatepassID == gatePassID && wt.isDelete == false); if (weighRecord == null) { response = ResponseConstructor <WeightRecordViewModel> .ConstructEnumerableData(ResponseCode.ERR_QUE_WEIGH_NO_FOUND, Mapper.Map <IEnumerable <WeightRecord>, IEnumerable <WeightRecordViewModel> >(weighRecord)); } else { response = ResponseConstructor <WeightRecordViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, Mapper.Map <IEnumerable <WeightRecord>, IEnumerable <WeightRecordViewModel> >(weighRecord)); } return(response); } catch (Exception) { return(response = ResponseConstructor <WeightRecordViewModel> .ConstructEnumerableData(ResponseCode.ERR_SEC_UNKNOW, null)); } }
public async Task <ResponseViewModel <QueueListViewModel> > GetTrucks(string truckCondition) { ResponseViewModel <QueueListViewModel> response; IEnumerable <QueueList> queryResult; IEnumerable <QueueListViewModel> truckOnQueueViewModel; // Check connection to database if (_unitOfWork.Exists() == false) { response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.ERR_DB_CONNECTION_FAILED, null); } else { switch (truckCondition) { case TRUCK_CONDITION_ALL: queryResult = (await _queueListRepository.GetManyAsync(c => c.isDelete == false, QueryIncludes.SECURITY_QUEUE_INCLUDES) ).ToArray().OrderBy(q => q.queueOrder).ToList(); truckOnQueueViewModel = Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queryResult); response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, truckOnQueueViewModel); break; case TRUCK_CONDITION_CALLING: queryResult = (await _queueListRepository.GetManyAsync(c => c.isDelete == false && (c.gatePass.state.ID == GatepassState.STATE_CALLING_1 || c.gatePass.state.ID == GatepassState.STATE_CALLING_2 || c.gatePass.state.ID == GatepassState.STATE_CALLING_3 ), QueryIncludes.SECURITY_QUEUE_INCLUDES) ).ToArray().OrderBy(q => q.queueOrder).ToList(); truckOnQueueViewModel = Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queryResult); response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, truckOnQueueViewModel); break; case TRUCK_CONDITION_WAITING_CALL: queryResult = (await _queueListRepository.GetManyAsync(c => c.isDelete == false && ( c.gatePass.state.ID == GatepassState.STATE_REGISTERED ), QueryIncludes.SECURITY_QUEUE_INCLUDES) ).ToArray().OrderBy(q => q.queueOrder).ToList(); truckOnQueueViewModel = Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queryResult); response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, truckOnQueueViewModel); break; case TRUCK_CONDITION_1XXX_WAITING_CALL: queryResult = (await _queueListRepository.GetManyAsync(c => c.isDelete == false && ( c.gatePass.state.ID == GatepassState.STATE_REGISTERED ) && c.gatePass.truckGroup.Code == TruckGroups.GROUP_1XXX, QueryIncludes.SECURITY_QUEUE_INCLUDES) ).ToArray().OrderBy(q => q.queueOrder).ToList(); truckOnQueueViewModel = Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queryResult); response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, truckOnQueueViewModel); break; case TRUCK_CONDITION_2XXX_WAITING_CALL: queryResult = (await _queueListRepository.GetManyAsync(c => c.isDelete == false && ( c.gatePass.state.ID == GatepassState.STATE_REGISTERED ) && c.gatePass.truckGroup.Code == TruckGroups.GROUP_2XXX, QueryIncludes.SECURITY_QUEUE_INCLUDES) ).ToArray().OrderBy(q => q.queueOrder).ToList(); truckOnQueueViewModel = Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queryResult); response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, truckOnQueueViewModel); break; case TRUCK_CONDITION_3XXX_WAITING_CALL: queryResult = (await _queueListRepository.GetManyAsync(c => c.isDelete == false && ( c.gatePass.state.ID == GatepassState.STATE_REGISTERED ) && c.gatePass.truckGroup.Code == TruckGroups.GROUP_3XXX, QueryIncludes.SECURITY_QUEUE_INCLUDES) ).ToArray().OrderBy(q => q.queueOrder).ToList(); truckOnQueueViewModel = Mapper.Map <IEnumerable <QueueList>, IEnumerable <QueueListViewModel> >(queryResult); response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.SUCCESS, truckOnQueueViewModel); break; default: response = ResponseConstructor <QueueListViewModel> .ConstructEnumerableData(ResponseCode.ERR_SEC_NOT_SUPPORT_CONDITION, null); break; } } return(response); }