コード例 #1
0
ファイル: ResultDto.cs プロジェクト: luhis/CodeGolf
 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));
 }
コード例 #2
0
 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));
 }
コード例 #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)));
        }
コード例 #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;
            }));
        }
コード例 #5
0
ファイル: PostDetailView.cs プロジェクト: luhis/shitforum
 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));
 }
コード例 #6
0
 public void IsNotEmpty_WhenEmptyGuid_ThrowsArgumentException()
 {
     ShouldThrow <ArgumentException>(
         ExceptionMessages.Guids_IsNotEmpty_Failed,
         () => Ensure.That(Guid.Empty, ParamName).IsNotEmpty(),
         () => EnsureArg.IsNotEmpty(Guid.Empty, ParamName));
 }
コード例 #7
0
ファイル: Hole.cs プロジェクト: luhis/CodeGolf
 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;
 }
コード例 #8
0
        public IActionResult Index(Guid locationId)
        {
            EnsureArg.IsNotEmpty(locationId);
            var query       = new GetLocationByIdQuery(locationId);
            var queryResult = QueryDispatcher.Execute <GetLocationByIdQuery, GetLocationByIdQueryResult>(query);

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

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

            return(Ok(queryResult.Employee));
        }
コード例 #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));
        }
コード例 #12
0
        public SystemNetFtpClient(string host, NetworkCredential credentials)
        {
            EnsureArg.IsNotEmpty(host);
            EnsureArg.IsNotNull(credentials);

            this.Host        = host;
            this.Credentials = credentials;
        }
コード例 #13
0
        public void IsNotEmpty_WhenStringIsEmpty_ThrowsArgumentException()
        {
            var value = string.Empty;

            AssertIsNotEmpty(
                () => Ensure.That(value, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(value, ParamName));
        }
コード例 #14
0
        public void IsNotEmpty_WhenStringHasValue_It_should_not_throw()
        {
            var value = "delta";

            ShouldNotThrow(
                () => Ensure.That(value, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(value, ParamName));
        }
コード例 #15
0
        public void IsNotEmpty_WhenStringIsNull_It_should_not_throw()
        {
            string value = null;

            ShouldNotThrow(
                () => Ensure.That(value, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(value, ParamName));
        }
コード例 #16
0
ファイル: ThreadDetailView.cs プロジェクト: luhis/shitforum
 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));
 }
コード例 #17
0
        public void IsNotEmpty_WhenNonEmptyGuid_ShouldNotThrow()
        {
            var guid = Guid.NewGuid();

            ShouldNotThrow(
                () => Ensure.That(guid, ParamName).IsNotEmpty(),
                () => EnsureArg.IsNotEmpty(guid, ParamName));
        }
コード例 #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));
 }
コード例 #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));
        }
コード例 #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;
 }
コード例 #21
0
        protected FtpClientBase(string host, NetworkCredential credential, int maxListingRecursiveParallelism)
        {
            EnsureArg.IsNotEmpty(host);
            EnsureArg.IsNotNull(credential);

            Host        = host;
            Credentials = credential;
            MaxListingRecursiveParallelism = maxListingRecursiveParallelism;
        }
コード例 #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));
 }
コード例 #23
0
        public GetFileQuery(string username, Guid dataFileId, FileType fileType)
        {
            EnsureArg.IsNotNullOrEmpty(username);
            EnsureArg.IsNotEmpty(dataFileId);

            Username   = username;
            DataFileId = dataFileId;
            FileType   = fileType;
        }
コード例 #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));
 }
コード例 #25
0
        public IActionResult UpdateStudentAttendance(Guid id_student)
        {
            EnsureArg.IsNotEmpty(id_student);

            var command = new UpdateStudentAttendanceCommand(id_student);

            CommandDispatcher.Execute(command);
            return(NoContent());
        }
コード例 #26
0
ファイル: GradeController.cs プロジェクト: radumaftei/MTE
        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));
        }
コード例 #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));
 }
コード例 #28
0
ファイル: Attempt.cs プロジェクト: luhis/CodeGolf
 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));
 }
コード例 #29
0
ファイル: ExamController.cs プロジェクト: radumaftei/MTE
        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));
        }
コード例 #30
0
        public IActionResult DeleteLocation(Guid tripId)
        {
            EnsureArg.IsNotEmpty(tripId);

            var command = new DeleteTripCommand(tripId);

            CommandDispatcher.Execute(command);

            return(NoContent());
        }