Пример #1
0
        public async Task <ViewResult> OverviewAsync(string pId)
        {
            if (String.IsNullOrEmpty(pId))
            {
                throw new Exception("The parameter [pId] is null or empty.");
            }

            Guid projectId = ShortGuid.Decode(pId);
            var  project   = await projectService.GetProjectAsync(projectId,
                                                                  this.ToNavPropertyString(nameof(IProjectPoco.Tasks)));

            var vmProject      = Mapper.Map <ProjectPreviewViewModel>(project);
            var resolvedStatus = lookupService.GetAllTaskStatus().First(p => p.Abrv == "CLOSED");

            var vm = new OverviewViewModel();

            vm.Project                    = vmProject;
            vm.Project.TaskCount          = project.Tasks.Count;
            vm.Project.LateTaskCount      = project.Tasks.Where(p => p.DueDate <= DateTime.UtcNow).Count();
            vm.Project.CompletedTaskCount = project.Tasks.Where(p => p.StatusId == resolvedStatus.Id).Count();

            ViewBag.Title     = project.Name;
            ViewBag.ProjectId = projectId;

            return(View("Overview", vm));
        }
Пример #2
0
        public void DecodeTest()
        {
            string value    = string.Empty; // TODO: Initialize to an appropriate value
            Guid   expected = new Guid();   // TODO: Initialize to an appropriate value
            Guid   actual;

            actual = ShortGuid.Decode(value);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        void Decode_fails_on_unexpected_string()
        {
            Assert.Throws <ArgumentException>(
                () => ShortGuid.Decode("Am I valid?")
                );

            Assert.Throws <FormatException>(
                () => ShortGuid.Decode("I am 22characters long")
                );
        }
        public async Task <ViewResult> TasksListAsync(string pId, int page = 1)
        {
            if (String.IsNullOrEmpty(pId))
            {
                throw new Exception("The parameter [pId] is null or empty.");
            }

            var vm = await GetListViewModelPaged(new PagingParameters(page, 9), ShortGuid.Decode(pId));

            return(View("_TasksList", vm.Tasks));
        }
        public async Task <ActionResult> ListAsync(string pId)
        {
            if (String.IsNullOrEmpty(pId))
            {
                throw new Exception("The parameter [pId] is null or empty.");
            }

            var vm = await GetListViewModelPaged(new PagingParameters(1, 9), ShortGuid.Decode(pId));

            return(View("List", vm));
        }
Пример #6
0
        public void ShortGuidDecodeTest()
        {
            const string gs  = "DwUBBA8PDAAPBAYFBAEEDw";
            const string gs1 = "0401050f-0f0f-000c-0f04-06050401040f";

            var g1 = ShortGuid.Decode(gs);
            var g2 = ShortGuid.Decode(gs1);

            Assert.AreEqual(g1, g2);
            Assert.AreEqual(g2, g1);
        }
Пример #7
0
        public void DoTest()
        {
            string shortGuid = ShortGuid.NewGuid();

            output.WriteLine($"shortGuid\t: {shortGuid}");

            string decodedGuid = ShortGuid.Decode(shortGuid).ToString();

            output.WriteLine($"decodedGuid\t: {decodedGuid}");

            Assert.Equal(shortGuid, ShortGuid.Encode(decodedGuid));
        }
        public static string GetCorrealtionIdString(byte[] buff)
        {
            var res = "";

            if (buff != null)
            {
                //encoding = encoding ?? Encoding.UTF8;
                var tmp = Encoding.ASCII.GetString(buff);
                res = ShortGuid.Decode(tmp).ToString();
            }

            return(res);
        }
Пример #9
0
        public ActionResult RedirectToProduct(string productId)
        {
            var encodedId = ShortGuid.Decode(productId);
            var product   = bus.RunQuery(new GetProductByIdQuery {
                ProductId = encodedId
            });

            if (product == null)
            {
                return(View("Error"));
            }

            return(Redirect(product.ProductUrl));
        }
        void invalid_strings_must_not_return_true_on_try_parse_with_strict_true()
        {
            // try parse should return false
            Assert.False(ShortGuid.TryParse(InvalidSampleShortGuidString, out ShortGuid strictSguid));

            // decode should throw
            Assert.Throws <FormatException>(
                () => ShortGuid.Decode(InvalidSampleShortGuidString)
                );

            // .ctor should throw
            Assert.Throws <FormatException>(
                () => new ShortGuid(InvalidSampleShortGuidString)
                );
        }
        public void ToShortGuid_GivenGuid_RetunsShortGuidRepresentationOfGuid()
        {
            var guid = Guid.Parse("7B9DA377-CD4B-431E-BE8E-16693D1B613C");

            var sg = guid.ToShortGuid();

            Assert.Equal("d6Ode0vNHkO-jhZpPRthPA", sg.Value);
            Assert.Equal(sg.Guid, guid);

            Assert.Equal(ShortGuid.Empty.Guid, Guid.Empty);

            var s = ShortGuid.Encode(guid.ToString());
            var g = ShortGuid.Decode(s);

            Assert.Equal(g, guid);

            Assert.True(sg == new ShortGuid(s));

            Assert.Null(ShortGuid.Decode("7-0l0eWeHRnv93947qn9bvSD"));
            Assert.Equal(ShortGuid.Empty.Value, new ShortGuid("7-0l0eWeHRnv93947qn9bvSD").Value);
        }
        public async Task <ActionResult> EditAsync(string tId)
        {
            if (String.IsNullOrEmpty(tId))
            {
                throw new Exception("The parameter [tId] is null or empty.");
            }

            var task = await taskService.GetTaskAsync(ShortGuid.Decode(tId), this.ToNavPropertyString(nameof(ITaskPoco.TaskComments)));

            if (task.TaskComments != null && task.TaskComments.Count() > 0)
            {
                task.TaskComments = task.TaskComments.OrderBy(p => p.DateUpdated);
            }

            var project = await projectService.GetProjectAsync(task.ProjectId,
                                                               this.ToNavPropertyString(nameof(IProjectPoco.ProjectUsers), this.ToNavPropertyString(nameof(IProjectUserPoco.User))));

            var vm = Mapper.Map <EditTaskViewModel>(task);

            SetEditActionViewBags(project);
            return(View("Edit", vm));
        }
 void StrictDecode_does_not_parse_longer_base64_string()
 {
     Assert.Throws <ArgumentException>(
         () => ShortGuid.Decode(LongerBase64String)
         );
 }
        public void Decode_ShouldDecodeStringFormOfShortGuid(string encoded, Guid expected)
        {
            var guid = ShortGuid.Decode(encoded);

            guid.Should().Be(expected);
        }
        void Decode_takes_expected_string()
        {
            Guid actual = ShortGuid.Decode(SampleShortGuidString);

            Assert.Equal(SampleGuid, actual);
        }
 void Decode_fails_on_unexpected_string()
 {
     Assert.Throws <FormatException>(
         () => ShortGuid.Decode("Am I valid?")
         );
 }
 void StrictDecode_parses_valid_shortGuid_strict_on()
 {
     ShortGuid.Decode(SampleShortGuidString);
 }