コード例 #1
0
        public IActionResult Create(string reference, string path, string name)
        {
            if (ModelState.IsValid)
            {
                gitCloneServices.GitClone(reference, path);
                gitInitService.GitInit(path);
                var repos = new Repos
                {
                    Name = name,
                    Path = path
                };

                _context.Add(repos);
                _context.SaveChanges();

                var analysis = new Analysis
                {
                    Date  = DateTime.Now,
                    Repos = _context.Repos.SingleOrDefault(x => x.Id == repos.Id)
                };

                _context.Add(analysis);
                _context.SaveChanges();
                int    RepoId     = repos.Id;
                string Path       = path;
                int    AnalysisId = analysis.Id;
                counterChange.CounterChangeFileInLocalrepositiry(RepoId, Path, AnalysisId);
            }

            return(View("Index"));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id, RepoId, Path")] AnalisisViewModel analisisViewModel)
        {
            if (ModelState.IsValid)
            {
                var analysis = new Analysis
                {
                    Date  = DateTime.Now,
                    Repos = _context.Repos.SingleOrDefault(x => x.Id == analisisViewModel.Id)
                };

                _context.Add(analysis);
                await _context.SaveChangesAsync();

                int    RepoId     = analisisViewModel.RepoId;
                string Path       = analisisViewModel.Path;
                int    AnalysisId = analysis.Id;
                await counterChange.CounterChangeFileInLocalrepositiry(RepoId, Path, AnalysisId);

                return(RedirectToAction("Index", "Repos"));
            }

            return(View("Create"));
        }