Ejemplo n.º 1
0
        public bool StatusNext(UpdateDTO request, Guid userId)
        {
            var currentStatus = Get(request.Id).Status;

            if (currentStatus == TestStatus.Completed)
            {
                return(false);
            }

            var analysisTestEntity = new AnalysisTestEntity() //AutoMapper
            {
                Id           = request.Id,
                TimeStamp    = request.TimeStamp,
                Status       = currentStatus + 1,
                DateModified = DateTime.UtcNow,
                ModifiedBy   = userId,
            };

            _context.AnalysisTests.Attach(analysisTestEntity);
            _context.Entry(analysisTestEntity).Property(x => x.Status).IsModified       = true;
            _context.Entry(analysisTestEntity).Property(x => x.DateModified).IsModified = true;
            _context.Entry(analysisTestEntity).Property(x => x.ModifiedBy).IsModified   = true;

            return(_context.SaveChanges() == 1);
        }
Ejemplo n.º 2
0
        public bool DeleteTest(int id, byte[] timeStamp)
        {
            var entity = new AnalysisTestEntity()
            {
                Id        = id,
                TimeStamp = timeStamp
            };

            _context.AnalysisTests.Remove(entity);
            return(_context.SaveChanges() == 1);
        }
Ejemplo n.º 3
0
        public bool Create(AnalysisCreateRQ request, Guid userId)
        {
            var analysisTestEntity = new AnalysisTestEntity() //AutoMapper
            {
                Name                = request.Name,
                STS_StudentId       = request.StudentId,
                STS_SynthesisTestId = request.SynthesisTestId,
                Status              = TestStatus.Scheduled,
                DateCreated         = DateTime.UtcNow,
                CreatedBy           = userId,
            };

            _context.AnalysisTests.Add(analysisTestEntity);
            return(_context.SaveChanges() == 1);
        }
Ejemplo n.º 4
0
        public AnalysisTestDTO(AnalysisTestEntity entity, AzureUserDTO createdByDetail, AzureUserDTO studentDetail)
        {
            Id        = entity.Id;
            TimeStamp = entity.TimeStamp;

            Name = entity.Name;
            SynthesisTestName = entity.SynthesisTestStudent.SynthesisTest.Name;
            TaskName          = entity.SynthesisTestStudent.SynthesisTest.Task.Name;
            TemplateName      = entity.SynthesisTestStudent.SynthesisTest.Task.Template.Name;
            Status            = (int)entity.Status;
            DateCreated       = entity.DateCreated.ToJsonString();

            CreatedBy = createdByDetail;
            Student   = studentDetail;
        }
Ejemplo n.º 5
0
        public bool UpdateName(UpdateNameRQ request, Guid userId)
        {
            var analysisTestEntity = new AnalysisTestEntity() //AutoMapper
            {
                Id           = request.Id,
                TimeStamp    = request.TimeStamp,
                Name         = request.Name,
                DateModified = DateTime.UtcNow,
                ModifiedBy   = userId,
            };

            _context.AnalysisTests.Attach(analysisTestEntity);
            _context.Entry(analysisTestEntity).Property(x => x.Name).IsModified         = true;
            _context.Entry(analysisTestEntity).Property(x => x.DateModified).IsModified = true;
            _context.Entry(analysisTestEntity).Property(x => x.ModifiedBy).IsModified   = true;

            return(_context.SaveChanges() == 1);
        }