Beispiel #1
0
        /// <summary>
        /// 更新给定的用户提交记录实体数据。
        /// </summary>
        /// <param name="entity">要更新的用户提交记录实体数据。</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="InvalidOperationException"/>
        /// <remarks>
        /// 若给定的用户提交记录实体数据不在数据库中,抛出 InvalidOperationException 异常。
        /// </remarks>
        public void UpdateSubmissionEntity(SubmissionEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            SubmissionEntity target = Submissions.Find(entity.Id);

            if (target == null)
            {
                throw new InvalidOperationException("给定的用户提交记录实体未在数据库中找到。");
            }

            // 更新用户提交记录实体数据。
            target.CodeFilename       = entity.CodeFilename;
            target.CreationTimestamp  = entity.CreationTimestamp;
            target.Language           = entity.Language;
            target.ProblemId          = entity.ProblemId;
            target.RemoteSubmissionId = entity.RemoteSubmissionId;
            target.Username           = entity.Username;
            target.VerdictResult      = entity.VerdictResult;
            target.VerdictStatus      = entity.VerdictStatus;
            target.VerdictTimestamp   = entity.VerdictTimestamp;

            SaveChanges();
        }
Beispiel #2
0
 /// <summary>
 /// 使用给定的提交 ID 查询提交实体对象。
 /// </summary>
 /// <param name="id">提交ID。</param>
 /// <returns>用户提交实体对象。若给定的提交 ID 不存在于数据集中,返回 null。</returns>
 public SubmissionEntity QuerySubmissionEntityById(int id)
 {
     return(Submissions.Find(id));
 }
        //***************************************************************
        //Name: FindSubmission()
        //Purpose: This method takes the assignment name as a parameter.It should
        //         return the Submission with the given assignment name.If it is
        //         not found then return null.
        //Input Type: string asn - assignment name
        //Output Type: Submission - returns submission object or null
        //***************************************************************
        public Submission FindSubmission(string asn)
        {
            Submission result = Submissions.Find(x => x.AssignmentName == asn);

            return(result);
        }