Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
 public bool Create(RequestDetailsModel bbrd)
 {
     try
     {
         _context.RequestDetails.Add(bbrd);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        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;
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
 public void CreateRequestObject()
 {
     reuest = new RequestDetailsModel();
 }
Esempio n. 14
0
 //[Authorize(Roles = "Admin")]
 public void Put(int id, RequestDetailsModel brrd)
 {
     _brrd.Update(brrd);
 }
Esempio n. 15
0
 //[Authorize(Roles = "Admin,User")]
 public void Post(RequestDetailsModel brrd)
 {
     _brrd.Create(brrd);
 }