Ejemplo n.º 1
0
        public async Task <IActionResult> List()
        {
            var tasks = _taskService.GetAll(_userId);

            ViewData["Moderators"] = (await _userService.GetAllAsync())
                                     .Select(user => new SelectListItem
            {
                Value = user.Id,
                Text  = String.Format("{0} {1} ({2})", user.LastName, user.FirstName, user.Email)
            }
                                             );
            ViewData["Statuses"] = _taskStatusService.GetAll()
                                   .Select(taskStatus => new SelectListItem
            {
                Value = taskStatus.Id.ToString(),
                Text  = taskStatus.Title
            });
            ViewData["Labels"] = (_labelService.GetAll(_userId))
                                 .Select(label => new SelectListItem
            {
                Value = label.Id.ToString(),
                Text  = label.Title,
            });
            ViewData["LabelColors"] = (_labelService.GetAll(_userId))
                                      .Select(label => new SelectListItem
            {
                Value = label.Id.ToString(),
                Text  = label.Color,
            });
            ViewData["CurrentUserID"] = _userId;
            return(View(tasks));
        }
Ejemplo n.º 2
0
        public void Should_Get_YourOwn_AllItems()
        {
            // Arrange
            var repository = new Mock <IRepository <Label> >();

            repository.Setup(u => u.GetAll()).Returns(() => new[]
            {
                new Label()
                {
                    Id = 1, Color = "#000000", Title = "nextTitle", UserId = "2"
                },
                new Label()
                {
                    Id = 10, Color = "#ffffff", Title = "title", UserId = "10"
                },
                new Label()
                {
                    Id = 1, Color = "#000000", Title = "nextTitle", UserId = "1"
                },
            });
            var service = new LabelService(_mapper, repository.Object);

            // Act
            var labels = service.GetAll("10").ToArray();

            // Assert
            Assert.Single(labels);
        }
Ejemplo n.º 3
0
 public JsonResult GetAll()
 {
     try
     {
         var models = _labelService.GetAll();
         return(Json(new { code = 200, data = models }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         LogService.Instance.AddAsync(Models.Level.Error, ex);
         return(Json(new { code = 500, msg = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            RequirePassword = await _userManager.HasPasswordAsync(user);

            if (RequirePassword)
            {
                if (!await _userManager.CheckPasswordAsync(user, Input.Password))
                {
                    ModelState.AddModelError(string.Empty, "Password not correct.");
                    return(Page());
                }
            }

            var labels = _labelService.GetAll(user.Id);

            foreach (var label in labels)
            {
                _labelService.Delete(label.Id, user.Id);
            }

            var result = await _userManager.DeleteAsync(user);

            var userId = await _userManager.GetUserIdAsync(user);

            if (!result.Succeeded)
            {
                throw new InvalidOperationException($"Unexpected error occurred deleteing user with ID '{userId}'.");
            }

            await _signInManager.SignOutAsync();

            _logger.LogInformation("User with ID '{UserId}' deleted themselves.", userId);

            return(Redirect("~/"));
        }
Ejemplo n.º 5
0
        public IActionResult List()
        {
            var labels = _labelService.GetAll(_userId);

            return(View(labels));
        }