Esempio n. 1
0
        public ActionResult ViewPerformers() //просмотр всех исполнителей
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context           = new QulixContext(connectionFactory);

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var performerService  = new PerformerService(uow, repositoryFactory);
                var performers        = performerService.GetAllPerformers();

                var model = new PerformerListViewModel()
                {
                    Performers = new List <PerformerModel>()
                };

                if (performers == null)
                {
                    return(View(model));
                }

                foreach (var performer in performers)
                {
                    model.Performers.Add(new PerformerModel()
                    {
                        Id             = performer.Id,
                        FirstName      = performer.FirstName,
                        LastName       = performer.LastName,
                        PatronymicName = performer.PatronymicName
                    });
                }

                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult AddPerformer(PerformerModel performerModel)
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context           = new QulixContext(connectionFactory);

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var performerService  = new PerformerService(uow, repositoryFactory);
                var performer         = performerService.CreatePerformer(performerModel.FirstName, performerModel.LastName, performerModel.PatronymicName);
                return(RedirectToAction("ViewPerformers", "Home"));
            }
        }
Esempio n. 3
0
        public ActionResult DeletePerformers(int idValue) //удаление исполнителя
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context           = new QulixContext(connectionFactory);

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var performerService  = new PerformerService(uow, repositoryFactory);
                performerService.RemovePerformer(idValue);
                uow.SaveChanges();
                return(RedirectToAction("ViewPerformers", "Home"));
            }
        }
Esempio n. 4
0
        public static ContestantDto ConvertToDto(this Contestant contestant)
        {
            var performerService = new PerformerService(new PerformerRepo(),
                                                        new DivisionRepo(), new PersonNameRepo(), new OrganizationRepo(), new ContestantPerformerRepo());

            var performers = performerService.GetContestantPerformers(contestant.Id);

            var scoreCardService = new ScoreCardService(new ScoreCardRepo(), new ScorableCriterionRepo(), new ContestantRepo());

            var totalScore = scoreCardService.GetContestantTotalScore(contestant.Id, new TimeSpan(0, 5, 0));

            return(new ContestantDto()
            {
                Id = contestant.Id,
                Performance = ConvertToDto(contestant.Performance),
                Performers = performers.ConvertToDto(),
                TotalScore = totalScore
            });
        }
Esempio n. 5
0
        public ActionResult AddTask() //добавление задачи
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context           = new QulixContext(connectionFactory);

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var performerService  = new PerformerService(uow, repositoryFactory);
                var performers        = performerService.GetAllPerformers();
                if (performers == null)
                {
                    performers = new List <Performer>();
                }
                var addTaskViewModel = new AddTaskViewModel()
                {
                    PerformerModels = performers
                };
                return(View(addTaskViewModel));
            }
        }
Esempio n. 6
0
        public ActionResult ViewTasks() //просмотр всех задач
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context           = new QulixContext(connectionFactory);

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var taskService       = new TaskService(uow, repositoryFactory);
                var tasks             = taskService.GetAllTasks();

                var model = new TaskListViewModel()
                {
                    Tasks = new List <TaskModel>()
                };

                var performerService = new PerformerService(uow, repositoryFactory);

                foreach (var task in tasks)
                {
                    var performer = performerService.GetPerformerById(task.PerformerId);
                    model.Tasks.Add(new TaskModel()
                    {
                        Id          = task.Id,
                        Name        = task.Name,
                        Workload    = task.Workload,
                        StartDate   = task.StartDate,
                        EndDate     = task.EndDate,
                        Status      = task.Status,
                        PerformerId = task.PerformerId,
                        Performer   = performer
                    });
                }

                return(View(model));
            }
        }
Esempio n. 7
0
 public PerformersController()
 {
     PerformerService = new PerformerService(new PerformerRepo(),
                                             new DivisionRepo(), new PersonNameRepo(), new OrganizationRepo(), new ContestantPerformerRepo());
 }