public async Task <RequestDetailsModel> GetRequestDetails(Guid requestId) { var requestDetailsModel = new RequestDetailsModel(); try { requestDetailsModel = await _requestRepository.GetRequestDetails(requestId); if (requestDetailsModel.AssignmentSolutionFileName != null) { requestDetailsModel.AssignmentSolutionUrl = await _blobHelper.GetBlobUriAsync("assignments", requestDetailsModel.AssignmentSolutionFileName.Trim()); } if (requestDetailsModel.ScoreCardFileName != null) { requestDetailsModel.ScoreCardUrl = await _blobHelper.GetBlobUriAsync("assignments", requestDetailsModel.ScoreCardFileName.Trim()); } if (requestDetailsModel.ErrorFileName != null) { requestDetailsModel.ErrorFileUrl = await _blobHelper.GetBlobUriAsync("assignments", requestDetailsModel.ErrorFileName.Trim()); } requestDetailsModel.AttemptsLog = await _requestRepository.GetAttemptsLog(requestId); requestDetailsModel.IsSuccess = true; } catch (Exception ex) { requestDetailsModel.Message = "Error Getting Request Details"; } return(requestDetailsModel); }
public async Task <IActionResult> GetRequestDetails(Guid requestId) { RequestDetailsModel requestDetailsModel = new RequestDetailsModel(); if (requestId.Equals(Guid.Empty)) { requestDetailsModel.Message = "Request ID not found."; return(new BadRequestObjectResult(requestDetailsModel)); } try { var requestDetails = await _requestManager.GetRequestDetails(requestId); if (requestDetails.IsSuccess == true) { return(Ok(requestDetails)); } else { return(StatusCode(500, requestDetails)); } } catch (Exception ex) { Logging.Logger.LogException(ex); requestDetailsModel.Message = "Error Getting Evaluators List"; return(StatusCode(500, requestDetailsModel.Message)); } }
public bool Create(RequestDetailsModel bbrd) { try { _context.RequestDetails.Add(bbrd); _context.SaveChanges(); return(true); } catch { return(false); } }
public async Task GetRequestDetails_Test_Exception() { var _requestManager = new RequestManager(null, null, null, null, null); RequestDetailsModel mockRequestDetailsModel = new RequestDetailsModel { Message = "Error Getting Request Details" }; Guid requestId = Guid.Parse("D2BD833D-35C3-46B2-A6AA-870B4B54A5A9"); var result = await _requestManager.GetRequestDetails(requestId); Assert.IsNotNull(result); var message = result as RequestDetailsModel; Assert.AreEqual(message.Message, mockRequestDetailsModel.Message); }
public async Task GetRequestDetails_Test_BothFileName() { Guid requestId = Guid.Parse("D2BD833D-35C3-46B2-A6AA-870B4B54A5A9"); RequestDetailsModel mockRequestDetailsModel = new RequestDetailsModel { AssignmentSolutionFileName = "assignment", ScoreCardFileName = "scoreCard" }; _mockRequestRepository.Setup(x => x.GetRequestDetails(It.IsAny <Guid>())).ReturnsAsync(mockRequestDetailsModel); var result = await requestManager.GetRequestDetails(requestId); Assert.IsNotNull(result); var status = (result as RequestDetailsModel).IsSuccess; Assert.AreEqual(status, true); }
public RequestDetailsModel Execute(RecordedRequestRequestModel request) { var report = _requestCache.RecentReports().SingleOrDefault(r => r.Id == request.Id); if(report == null) { throw new ArgumentException("{0} does not exist".ToFormat(request.Id)); } var model = new RequestDetailsModel { Report = report, Root = Gather(report) }; return model; }
public bool Update(RequestDetailsModel brrd) { try { var item = _context.RequestDetails.FirstOrDefault(x => x.Id == brrd.Id); item.BookID = brrd.BookID; item.RequestID = brrd.RequestID; _context.SaveChanges(); return(true); } catch { return(false); } }
public async Task GetRequestDetails_Test_Ok() { Guid requestId = Guid.Parse("D2BD833D-35C3-46B2-A6AA-870B4B54A5A9"); RequestDetailsModel mockRequestDetailsModel = new RequestDetailsModel { IsSuccess = true }; _mockRequestManager.Setup(x => x.GetRequestDetails(It.IsAny <Guid>())).ReturnsAsync(mockRequestDetailsModel); var result = await requestController.GetRequestDetails(requestId); Assert.IsNotNull(result); var status = (((result as OkObjectResult).Value) as RequestDetailsModel); Assert.AreEqual(status.IsSuccess, mockRequestDetailsModel.IsSuccess); }
public RequestDetailsModel Get(RecordedRequestRequestModel request) { var report = _requestCache.RecentReports().SingleOrDefault(r => r.Id == request.Id); if (report == null) { throw new UnknownObjectException(request.Id); } var model = new RequestDetailsModel { Report = report, Root = Gather(report) }; return(model); }
public bool CreateRequest(int userId, List <int> bookIds) { try { var checkMonth = _context.Requests.Count(x => x.RequestUserId == userId && x.RequestDate.Month == DateTime.Now.Month && x.RequestDate.Year == DateTime.Now.Year); if (bookIds.Count() > 5 || checkMonth > 2) { return(false); } else { var request = new RequestModel { RequestUserId = userId, RequestDate = DateTime.Now, RequestStatus = Status.Waiting }; _context.Requests.Add(request); _context.SaveChanges(); foreach (var item in bookIds) { var requestdetail = new RequestDetailsModel { RequestID = request.RequestID, BookID = item }; _context.RequestDetails.Add(requestdetail); } _context.SaveChanges(); return(true); } } catch { return(false); } }
public RequestDetailsModel Execute(RecordedRequestRequestModel request) { var report = _requestCache.RecentReports().SingleOrDefault(r => r.Id == request.Id); if(report == null) { throw new ArgumentException("{0} does not exist".ToFormat(request.Id)); } var model = new RequestDetailsModel { Report = report, Root = Gather(report), Chain = _chainVisualizer.VisualizerFor(report.BehaviorId), Logs = report .Steps .Where(s => s.Details is RequestLogEntry) .Select(s => s.Details) .Cast<RequestLogEntry>() .ToList() }; return model; }
public RequestDetailsModel Execute(RecordedRequestRequestModel request) { var report = _requestCache.RecentReports().SingleOrDefault(r => r.Id == request.Id); if (report == null) { throw new ArgumentException("{0} does not exist".ToFormat(request.Id)); } var model = new RequestDetailsModel { Report = report, Root = Gather(report), Chain = _chainVisualizer.VisualizerFor(report.BehaviorId), Logs = report .Steps .Where(s => s.Details is RequestLogEntry) .Select(s => s.Details) .Cast <RequestLogEntry>() .ToList() }; return(model); }
public void CreateRequestObject() { reuest = new RequestDetailsModel(); }
//[Authorize(Roles = "Admin")] public void Put(int id, RequestDetailsModel brrd) { _brrd.Update(brrd); }
//[Authorize(Roles = "Admin,User")] public void Post(RequestDetailsModel brrd) { _brrd.Create(brrd); }