public CommonResult<int> Create(CreateTaskRequestData requestData, string userName)
        {
            using (var context = ContextFactory.GetDbContext(_dbConfiguration))
            {
                var data = new Task();
                data.DateOfCreation = DateTime.Now;
                data.Description = requestData.Description;
                data.IsActive = requestData.IsActive;
                data.Language = requestData.SelectedLanguage;
                data.Name = requestData.Name;
                data.User = context.Users.First(x => x.UserName == userName);

                if (requestData.SelectedGroupId != -1)
                {
                    data.Group = context.Groups.First(x => x.Id == requestData.SelectedGroupId);
                }

                context.Tasks.Add(data);
                context.SaveChanges();

                return CommonResult<int>.Success(data.Id);
            }
        }
Beispiel #2
0
        public CommonResult<CreatedTaskResultData> Create(CreateTaskRequestData requestData)
        {
            var result = _tasksRepository.Create(requestData, StaticManager.UserName);

            if (result.IsSuccess)
            {
                var repositoryName = GenerateRepositoryName(StaticManager.UserName);
                var createRepositoryRequestData = new CreateRepositoryRequestData()
                {
                    OwnerName = StaticManager.UserName,
                    RepositoryName = repositoryName,
                    IsPublic = false,
                    IsAnonymousPushAllowed = false
                };

                var webClient = _webClientFactory.CreateWebClient();
                webClient.UploadString(_sourceControlUrl + "Repository/Create", JsonConvert.SerializeObject(createRepositoryRequestData));

                _tasksRepository.AddGitRepositoryToTask(result.Item, repositoryName);

                var data = new CreatedTaskResultData();
                data.Id = result.Item;
                data.RepositoryLink = UrlFormatter.FormatSourceControlUrl(repositoryName);
                data.ShouldActivateTask = requestData.IsActive;

                return CommonResult<CreatedTaskResultData>.Success(data);
            }

            return CommonResult<CreatedTaskResultData>.Failure(result.ErrorMessage);
        }
        public IActionResult Create(CreateTaskRequestData requestData)
        {
            var result = _tasksService.Create(requestData);

            return Json(result);
        }
Beispiel #4
0
        public CreateTaskRequestData GetDataForCreate()
        {
            var data = new CreateTaskRequestData();
            data.UserGroups = new List<UserGroupData>
            {
                new UserGroupData() { Id = -1, Name = "Brak" }
            };
            data.UserGroups.AddRange(Mapper.Map<List<UserGroupData>>(_groupsRepository.GetAllForUser(StaticManager.UserName, true).Item));
            data.AvailableLanguages = default(LanguageEnum).GenerateDisplayDataList();

            return data;
        }