Beispiel #1
0
 public ResultDto(int rank, string loginName, string avatarUri, int score)
 {
     this.Rank      = rank;
     this.LoginName = EnsureArg.IsNotEmpty(loginName, nameof(loginName));
     this.Score     = score;
     this.AvatarUri = EnsureArg.IsNotNull(avatarUri, nameof(avatarUri));
 }
 public CatalogThreadOverView(Guid threadId, string subject, Board board, PostOverView op)
 {
     this.ThreadId = EnsureArg.IsNotEmpty(threadId, nameof(threadId));
     Board         = EnsureArg.IsNotNull(board, nameof(board));
     Subject       = EnsureArg.IsNotNull(subject, nameof(subject));
     OP            = EnsureArg.IsNotNull(op, nameof(op));
 }
Beispiel #3
0
        private static string CamelCase(string str)
        {
            EnsureArg.IsNotEmpty(str, nameof(str));
            EnsureArg.IsTrue(str.Length > 1, nameof(str));

            return(string.Concat(char.ToLowerInvariant(str[0]), str.Substring(1)));
        }
Beispiel #4
0
        public Result <decimal> GetPriceForMonth(Guid companyId, Month month, int violations)
        {
            EnsureArg.IsNotEmpty(companyId);
            EnsureArg.IsGte(violations, 0);

            var companyOrNothing = companyRepository.GetById(companyId);

            if (companyOrNothing.HasNoValue)
            {
                return(Result.Fail <decimal>("Company does not exist"));
            }

            var company = companyOrNothing.Value;

            var subscriptionOrNothing = company.SubscriptionFor(month);

            return(subscriptionOrNothing.ToResult("No subscription for given month!")
                   .OnSuccess(subscription =>
            {
                var employeesCost = company.NumberOfEmployees * subscription.Subscription.Price;
                var exceedingNumberOfViolations = company.GetExceedingNumberOfViolations(violations);
                var violationsCost = exceedingNumberOfViolations * violationCost;

                return employeesCost + violationsCost;
            }));
        }
Beispiel #5
0
 public PostContextView(Guid threadId, string threadSubject, BoardOverView board, PostOverView post)
 {
     ThreadId      = EnsureArg.IsNotEmpty(threadId, nameof(threadId));
     ThreadSubject = EnsureArg.IsNotNull(threadSubject, nameof(threadSubject));
     Board         = EnsureArg.IsNotNull(board, nameof(board));
     Post          = EnsureArg.IsNotNull(post, nameof(post));
 }
Beispiel #6
0
 public void IsNotEmpty_WhenEmptyGuid_ThrowsArgumentException()
 {
     ShouldThrow <ArgumentException>(
         ExceptionMessages.Guids_IsNotEmpty_Failed,
         () => Ensure.That(Guid.Empty, ParamName).IsNotEmpty(),
         () => EnsureArg.IsNotEmpty(Guid.Empty, ParamName));
 }
Beispiel #7
0
 public Hole(Guid holeId, Guid challengeId, TimeSpan duration, int rank)
 {
     this.HoleId      = EnsureArg.IsNotEmpty(holeId, nameof(holeId));
     this.ChallengeId = EnsureArg.IsNotEmpty(challengeId, nameof(challengeId));
     this.Duration    = duration;
     this.Rank        = rank;
 }
        public IActionResult Index(Guid locationId)
        {
            EnsureArg.IsNotEmpty(locationId);
            var query       = new GetLocationByIdQuery(locationId);
            var queryResult = QueryDispatcher.Execute <GetLocationByIdQuery, GetLocationByIdQueryResult>(query);

            return(Ok(queryResult.Location));
        }
Beispiel #9
0
        protected FtpClientConnectionBase(string host, NetworkCredential credential)
        {
            EnsureArg.IsNotEmpty(host);
            EnsureArg.IsNotNull(credential);

            Host        = host;
            Credentials = credential;
        }
        public IActionResult Index(Guid employeeId)
        {
            EnsureArg.IsNotEmpty(employeeId);
            var query       = new GetEmployeeByIdQuery(employeeId);
            var queryResult = QueryDispatcher.Execute <GetEmployeeByIdQuery, GetEmployeeByIdQueryResult>(query);

            return(Ok(queryResult.Employee));
        }
Beispiel #11
0
        public IActionResult Index(Guid tripId)
        {
            EnsureArg.IsNotEmpty(tripId);
            var query       = new GetTripByIdQuery(tripId);
            var queryResult = QueryDispatcher.Execute <GetTripByIdQuery, GetTripByIdQueryResult>(query);

            return(Ok(queryResult.Trip));
        }
Beispiel #12
0
        public SystemNetFtpClient(string host, NetworkCredential credentials)
        {
            EnsureArg.IsNotEmpty(host);
            EnsureArg.IsNotNull(credentials);

            this.Host        = host;
            this.Credentials = credentials;
        }
        public void IsNotEmpty_WhenStringIsEmpty_ThrowsArgumentException()
        {
            var value = string.Empty;

            AssertIsNotEmpty(
                () => Ensure.That(value, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(value, ParamName));
        }
        public void IsNotEmpty_WhenStringHasValue_It_should_not_throw()
        {
            var value = "delta";

            ShouldNotThrow(
                () => Ensure.That(value, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(value, ParamName));
        }
        public void IsNotEmpty_WhenStringIsNull_It_should_not_throw()
        {
            string value = null;

            ShouldNotThrow(
                () => Ensure.That(value, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(value, ParamName));
        }
Beispiel #16
0
 public ThreadDetailView(Guid threadId, string subject, ThreadStats stats, BoardOverView board, IReadOnlyList <PostOverView> posts)
 {
     ThreadId   = EnsureArg.IsNotEmpty(threadId, nameof(threadId));
     Subject    = EnsureArg.IsNotNull(subject, nameof(subject));
     Stats      = EnsureArg.IsNotNull(stats, nameof(stats));
     this.Board = EnsureArg.IsNotNull(board, nameof(board));
     Posts      = EnsureArg.IsNotNull(posts, nameof(posts));
 }
Beispiel #17
0
        public void IsNotEmpty_WhenNonEmptyGuid_ShouldNotThrow()
        {
            var guid = Guid.NewGuid();

            ShouldNotThrow(
                () => Ensure.That(guid, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(guid, ParamName));
        }
Beispiel #18
0
 public ThreadOverView(Guid threadId, string subject, PostOverView firstPost, IReadOnlyList <PostOverView> finalPosts, ThreadOverViewStats stats)
 {
     this.ThreadId = EnsureArg.IsNotEmpty(threadId, nameof(threadId));
     Subject       = EnsureArg.IsNotNull(subject, nameof(subject));
     OP            = EnsureArg.IsNotNull(firstPost, nameof(firstPost));
     FinalPosts    = EnsureArg.IsNotNull(finalPosts, nameof(finalPosts));
     Stats         = EnsureArg.IsNotNull(stats, nameof(stats));
 }
Beispiel #19
0
        public IActionResult GetStudent(Guid id_student)
        {
            EnsureArg.IsNotEmpty(id_student);
            var query = new GetStudentByIdQuery(id_student);

            var queryResult = QueryDispatcher.Execute <GetStudentByIdQuery, GetStudentByIdQueryResult>(query);

            return(Ok(queryResult.Student));
        }
Beispiel #20
0
 public PostOverView(Guid id, DateTime created, string name, string ipHash, string comment, Option <File> file)
 {
     Id      = EnsureArg.IsNotEmpty(id, nameof(id));
     Created = EnsureArg.IsNotDefault(created, nameof(created));
     Name    = EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name));
     IpHash  = EnsureArg.IsNotNull(ipHash, nameof(ipHash));
     Comment = EnsureArg.IsNotNullOrWhiteSpace(comment, nameof(comment));
     File    = file;
 }
Beispiel #21
0
        protected FtpClientBase(string host, NetworkCredential credential, int maxListingRecursiveParallelism)
        {
            EnsureArg.IsNotEmpty(host);
            EnsureArg.IsNotNull(credential);

            Host        = host;
            Credentials = credential;
            MaxListingRecursiveParallelism = maxListingRecursiveParallelism;
        }
Beispiel #22
0
 public AttemptDto(int rank, Guid id, string loginName, string avatar, int score, DateTime timeStamp)
 {
     this.Rank      = rank;
     this.Id        = EnsureArg.IsNotEmpty(id, nameof(id));
     this.LoginName = EnsureArg.IsNotEmpty(loginName, nameof(loginName));
     this.Score     = score;
     this.Avatar    = EnsureArg.IsNotEmpty(avatar, nameof(avatar));
     this.TimeStamp = EnsureArg.IsNotDefault(timeStamp, nameof(timeStamp));
 }
Beispiel #23
0
        public GetFileQuery(string username, Guid dataFileId, FileType fileType)
        {
            EnsureArg.IsNotNullOrEmpty(username);
            EnsureArg.IsNotEmpty(dataFileId);

            Username   = username;
            DataFileId = dataFileId;
            FileType   = fileType;
        }
Beispiel #24
0
 public Post(Guid id, Guid threadId, DateTime created, string name, string comment, bool isSage, string ipAddress) : base(id)
 {
     ThreadId  = EnsureArg.IsNotEmpty(threadId, nameof(threadId));
     Created   = EnsureArg.IsNotDefault(created, nameof(created));
     Name      = EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name));
     Comment   = EnsureArg.IsNotNullOrWhiteSpace(comment, nameof(comment));
     IsSage    = isSage;
     IpAddress = EnsureArg.IsNotNull(ipAddress, nameof(ipAddress));
 }
Beispiel #25
0
        public IActionResult UpdateStudentAttendance(Guid id_student)
        {
            EnsureArg.IsNotEmpty(id_student);

            var command = new UpdateStudentAttendanceCommand(id_student);

            CommandDispatcher.Execute(command);
            return(NoContent());
        }
Beispiel #26
0
        public IActionResult AddGrade(Guid studentId, [FromBody] GradeDto grade)
        {
            EnsureArg.IsNotEmpty(studentId);

            var command = new AddGradeCommand(grade, studentId);

            CommandDispatcher.Execute(command);
            return(Created("/api/students/{studentId}/grades", command));
        }
Beispiel #27
0
 public AttemptCodeDto(Guid id, string loginName, string avatar, int score, string timeStamp, string code)
 {
     this.Id        = EnsureArg.IsNotEmpty(id, nameof(id));
     this.LoginName = EnsureArg.IsNotEmpty(loginName, nameof(loginName));
     this.Score     = score;
     this.Code      = EnsureArg.IsNotNull(code, nameof(code));
     this.Avatar    = EnsureArg.IsNotEmpty(avatar, nameof(avatar));
     this.TimeStamp = EnsureArg.IsNotNull(timeStamp, nameof(timeStamp));
 }
Beispiel #28
0
 public Attempt(Guid id, int userId, Guid holeId, string code, int score, DateTime timeStamp)
 {
     this.Id        = EnsureArg.IsNotEmpty(id, nameof(id));
     this.UserId    = EnsureArg.IsNotDefault(userId, nameof(userId));
     this.HoleId    = EnsureArg.IsNotEmpty(holeId, nameof(holeId));
     this.Code      = EnsureArg.IsNotNull(code, nameof(code));
     this.Score     = score;
     this.TimeStamp = EnsureArg.IsNotDefault(timeStamp, nameof(timeStamp));
 }
Beispiel #29
0
        public IActionResult GetAllStudentsByExamId(Guid exam_Id)
        {
            EnsureArg.IsNotEmpty(exam_Id);

            var query       = new GetAllStudentsByExamIdQuery(exam_Id);
            var queryResult =
                QueryDispatcher.Execute <GetAllStudentsByExamIdQuery, GetAllStudentsByExamIdQueryResult>(query);

            return(Ok(queryResult.Students));
        }
Beispiel #30
0
        public IActionResult DeleteLocation(Guid tripId)
        {
            EnsureArg.IsNotEmpty(tripId);

            var command = new DeleteTripCommand(tripId);

            CommandDispatcher.Execute(command);

            return(NoContent());
        }