Example #1
0
        public void AddDemoTicket()
        {
            var ticketUnitOfwork = new TicketUnitOfWork();
            var userUnitOfwork   = new UserUnitOfWork();
            var random           = new Random();

            var projects          = ticketUnitOfwork.ProjectRepository.All().ToList();
            var defaultProjectId  = projects[random.Next(0, projects.Count)].ProjectId;
            var areas             = ticketUnitOfwork.AreaRepository.Where(a => a.ProjectId == defaultProjectId).ToList();
            var defaultAreaId     = areas[random.Next(0, areas.Count)].AreaId;
            var categories        = ticketUnitOfwork.CategoryRepository.All().ToList();
            var defaultCategoryId = categories[random.Next(0, categories.Count)].CategoryId;
            var priorities        = ticketUnitOfwork.PriorityRepository.All().ToList();
            var defaultPriorityId = priorities[random.Next(0, priorities.Count)].PriorityId;
            var normalUsers       = userUnitOfwork.GetNormalUsers().ToList();
            var projectManagers   = userUnitOfwork.GetProjectManagers().ToList();
            var statusId          = (int)TicketStatus.Open;
            var defaultUserId     = normalUsers[random.Next(0, normalUsers.Count)].Id;
            var ownerId           = projectManagers[random.Next(0, projectManagers.Count)].Id;

            var data = new TicketData
            {
                Title      = "FirstIssue",
                Content    = "this is a content",
                ProjectId  = defaultProjectId,
                CategoryId = defaultCategoryId,
                PriorityId = defaultPriorityId,
                UserId     = defaultUserId,
                CreatedBy  = ownerId,
                AreaId     = defaultAreaId,
                IsBillable = false
            };

            ticketUnitOfwork.NewTicket(data);
        }
 public TicketUnitOfWorkValidator(MyTasks.Data.UnitOfWorks.TicketUnitOfWork uo)
 {
     unitOfWork = uo;
     RuleFor(x => x.Title).NotEmpty().WithMessage(Localization.Desktop.Desktop.TitleIsRequired);
     RuleFor(x => x.ProjectId).NotEmpty().WithMessage(Localization.Desktop.Desktop.ProjectIsRequired);
     RuleFor(x => x.AreaId).NotEmpty().WithMessage(Localization.Desktop.Desktop.AreaIdIsRequired);
     RuleFor(x => x.CategoryId).NotEmpty().WithMessage(Localization.Desktop.Desktop.CategoryIdIsRequired);
     RuleFor(x => x.UserId).NotEmpty().WithMessage(Localization.Desktop.Desktop.UserIdIsRequired);
     RuleFor(x => x.PriorityId).NotEmpty().WithMessage(Localization.Desktop.Desktop.PriorityIdIsRequired);
     RuleFor(x => x.Content).NotEmpty().WithMessage(Localization.Desktop.Desktop.ContentIsRequired);
 }