public async Task <ResponseViewModel <UpdateLaneStatusViewModel> > UpdateLaneStatus([FromBody] UpdateLaneStatusViewModel updateLaneStatusViewModel) { return(await _weightService.UpdateLaneStatus(updateLaneStatusViewModel)); }
public async Task <ResponseViewModel <UpdateLaneStatusViewModel> > UpdateLaneStatus(UpdateLaneStatusViewModel updateLaneStatusViewModel) { ResponseViewModel <UpdateLaneStatusViewModel> response = new ResponseViewModel <UpdateLaneStatusViewModel>(); //Get lane from laneName var laneRecord = await _laneRepository.GetAsync(l => l.nameVi.Equals(updateLaneStatusViewModel.laneName), null); if (laneRecord != null) { //Check current status if (laneRecord.status == 0) // If lane block { laneRecord.status = 1; laneRecord.usingStatus = 0; } else { if (laneRecord.usingStatus == 0) // If lane free { laneRecord.status = 0; laneRecord.usingStatus = 0; } else // If lane using { response.errorCode = -1; } } } _laneRepository.Update(laneRecord); await _unitOfWork.SaveChangesAsync(); await _queueService.ReOrderQueue(); return(response); }