Inheritance: IAssessmentResult
Ejemplo n.º 1
0
        public Guid AddCandidate(string surname, string forenames)
        {
            if (string.IsNullOrWhiteSpace(surname))
            {
                throw new ArgumentException("Surname must have a value.", "surname");
            }

            if (string.IsNullOrWhiteSpace(forenames))
            {
                throw new ArgumentException("Forenames must have a value.", "forenames");
            }

            var assessmentResult = new AssessmentResult(surname, forenames);
            if (this.results.Contains(assessmentResult))
            {
                throw new UniqueConstraintException(string.Format("A candidate with name \"{0}, {1}\" alread exists.", surname, forenames));
            }

            this.results.Add(assessmentResult);
            return assessmentResult.Id;
        }
Ejemplo n.º 2
0
        public void SetCandidateNames(Guid id, string surname, string forenames)
        {
            if (string.IsNullOrWhiteSpace(surname))
            {
                throw new ArgumentException("Surname must have a value.", "surname");
            }

            if (string.IsNullOrWhiteSpace(forenames))
            {
                throw new ArgumentException("Forenames must have a value.", "forenames");
            }

            var existingResult = this.results.Single(r => r.Id == id);
            var newResult = new AssessmentResult(id, surname, forenames, existingResult.Result);

            if (this.results.Where(r => r.Id != existingResult.Id).Any(r => r.Surname == surname && r.Forenames == forenames))
            {
                throw new UniqueConstraintException(string.Format("A candidate with name \"{0}, {1}\" alread exists.", surname, forenames));
            }

            this.results.Remove(existingResult);
            this.results.Add(newResult);
        }
Ejemplo n.º 3
0
        public void SetCandidateResult(Guid id, decimal? result)
        {
            if (result.HasValue)
            {
                if (result < 0)
                {
                    throw new ArgumentOutOfRangeException("result", "Result be a positive number.");
                }

                if (this.TotalMarks.HasValue && result > this.TotalMarks)
                {
                    throw new ArgumentOutOfRangeException(
                        "result", "Result must be lower than or equal to the total marks.");
                }
            }

            var existingResult = this.results.Single(r => r.Id == id);
            var newResult = new AssessmentResult(id, existingResult.Surname, existingResult.Forenames, result);
            this.results.Remove(existingResult);
            this.results.Add(newResult);
        }