public async Task <ApiResult <bool> > CreateRepo(CreateRepoRequest request) { var schedule = await _context.Schedules.FindAsync(request.Id_Schedule); //if (schedule.Date != DateTime.UtcNow.AddHours(7).Date) //{ // return new ApiErrorResult<bool>("Ngày tạo Không hợp lệ"); //} if (await _context.HistoryAttendances.FindAsync(request.Id_Schedule) != null) { return(new ApiSuccessResult <bool>("Kho chứa đã được tạo")); } if (schedule.Id_Course != request.Id_Course) { return(new ApiErrorResult <bool>("Không tồn tại khóa học")); } var data = new HistoryAttendance() { Id_HistoryAttendace = request.Id_Schedule, Id_Schedule = request.Id_Schedule, Id_Course = request.Id_Course, DateAttendance = DateTime.UtcNow.AddHours(7).Date, Id_EquipmentTeacher = request.Id_EquipmentTeacher, }; _context.HistoryAttendances.Add(data); await _context.SaveChangesAsync(); return(new ApiSuccessResult <bool>("Bạn đã tạo thành công")); }
public ActionResult Create(CreateRepoRequest request) { string repoPath = null; if (ModelState.IsValid) { var invalid = Path.GetInvalidFileNameChars(); if (request.RepoName.Any(c => invalid.Contains(c))) { ModelState.AddModelError("RepoName", "Repository name must be a valid folder name."); } else { var resourceInfo = this.FileManager.GetResourceInfo(request.RepoName); if (resourceInfo.FileSystemInfo == null) { ModelState.AddModelError("RepoName", "You do not have permission to create this repository."); } if (resourceInfo.Type != ResourceType.NotFound) { ModelState.AddModelError("RepoName", "There is already an object at that location."); } repoPath = resourceInfo.FullPath; } } if (!ModelState.IsValid) { return(View(request)); } try { GitUtilities.CreateRepo(repoPath); } catch (GitErrorException ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(request)); } io::File.WriteAllText(Path.Combine(repoPath, "description"), request.Description); GitUtilities.ExecutePostCreateHook(repoPath); return(RedirectToAction("ViewRepo", "Browse", new { repo = request.RepoName })); }
public static void Main() { // Settings needed to connect and use the Batching Service. string user = ConfigurationManager.AppSettings["User"]; string password = ConfigurationManager.AppSettings["Password"]; string batchingServiceEndpointAddress = ConfigurationManager.AppSettings["BatchingServiceEndpointAddress"]; // Creation of a channel connected to the Batching Service. var endpoint = new EndpointAddress(batchingServiceEndpointAddress); var binding = new BasicHttpBinding(); ChannelFactory <IGitHubSoapBatchingService> channelFactory = new ChannelFactory <IGitHubSoapBatchingService>(binding, endpoint); var serviceChannel = channelFactory.CreateChannel(); // Build a Request to create a new repository. var newRepo = new RepoCreate { name = "Another-Test-Repository", description = "Just another test repository", has_downloads = true, has_issues = true, has_wiki = false, @private = false }; var createRepoRequest = new CreateRepoRequest { User = user, Password = password, CreateRepo = newRepo }; // Build a Request to get the created repository. var getRepoRequest = new GetRepoRequest { User = user, Repo = newRepo.name }; // Build a request to edit the created repository. var editRepo = new RepoEdit { has_wiki = true, name = newRepo.name }; var editRepoRequest = new EditRepoRequest { User = user, Password = password, Repo = newRepo.name, EditRepo = editRepo }; // Call the Batching Service. var results = serviceChannel.Process(createRepoRequest, getRepoRequest, editRepoRequest); // Get the indexed responses. var createRepoResponse = (RepoResponse)results[0]; var getRepoResponse = (RepoResponse)results[1]; var editRepoResponse = (RepoResponse)results[2]; }
public async Task <IActionResult> Create(CreateRepoRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _teacherService.CreateRepo(request); if (result.IsSuccessed == false) { return(BadRequest(result)); } return(Ok(result)); }