Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email")] Judge judge)
        {
            if (id != judge.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(judge);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JudgeExists(judge.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(judge));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Researcher researcher)
        {
            if (id != researcher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(researcher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ResearcherExists(researcher.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(researcher));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ShowTitle,ShowTimer, AddComment")] ExperimentParameters experimentParameters)
        {
            if (id != experimentParameters.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(experimentParameters);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExperimentParametersExists(experimentParameters.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(experimentParameters));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,FileName,Description")] Artefact artefact)
        {
            if (id != artefact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(artefact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArtefactExists(artefact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(artefact));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FunctionName,Filename,Description,Valid")] Algorithm algorithm)
        {
            if (id != algorithm.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(algorithm);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlgorithmExists(algorithm.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(algorithm));
        }
Пример #6
0
        public async Task GetWinners([FromBody] dynamic data, int?id)
        {
            string   winner          = data.Winner;
            var      winningArtefact = new Artefact();
            DateTime timeJudgement   = DateTime.ParseExact((string)data.TimeOfPairing, "dd/MM/yyyy, HH:mm:ss", CultureInfo.InvariantCulture);
            int      elapsedTime     = (int)data.ElapsedTime;
            string   comment         = data.Comment;
            var      user            = GetCurrentUserAsync().Result.Id;
            Pairing  pairing         = new Pairing
            {
                ExperimentId = (int)id,
                Experiment   = await _context.Experiment.FirstOrDefaultAsync(m => m.Id == id),
                JudgeLoginID = user
            };
            List <ArtefactPairing> pairOfScripts = new List <ArtefactPairing>();
            string   scriptOne   = data.ArtefactPairings["item1"];
            Artefact artefactOne = await _context.Artefact
                                   .FirstOrDefaultAsync(m => m.FilePath == scriptOne);

            ArtefactPairing one = new ArtefactPairing
            {
                ArtefactId = artefactOne.Id,
                PairingId  = pairing.Id,
                Artefact   = artefactOne
            };
            string   scriptTwo   = data.ArtefactPairings["item2"];
            Artefact artefactTwo = await _context.Artefact
                                   .FirstOrDefaultAsync(m => m.FilePath == scriptTwo);

            ArtefactPairing two = new ArtefactPairing
            {
                ArtefactId = artefactTwo.Id,
                PairingId  = pairing.Id,
                Artefact   = artefactTwo
            };

            if (artefactOne.FilePath == winner)
            {
                winningArtefact = artefactOne;
            }
            else
            {
                winningArtefact = artefactTwo;
            }
            pairOfScripts.Add(one);
            pairOfScripts.Add(two);
            pairing.ArtefactPairings = pairOfScripts;
            pairing.Winner           = winningArtefact;
            pairing.TimeOfPairing    = timeJudgement;
            pairing.ElapsedTime      = elapsedTime;
            pairing.Comment          = comment;
            if (ModelState.IsValid)
            {
                _context.Update(pairing);
                await _context.SaveChangesAsync();
            }
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] Experiment experiment)
        {
            if (id != experiment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var form = Request.Form;
                    experiment.ExpArtefacts = new List <ExpArtefact>();
                    experiment.ExpJudges    = new List <ExpJudge>();
                    var    expID        = experiment.Id;
                    string expNameParam = form["Parameters"];
                    var    expParam     = await _context.ExperimentParameters
                                          .FirstOrDefaultAsync(m => m.Description == expNameParam);

                    int expParamID = expParam.Id;
                    experiment.ExperimentParametersId = expParamID;
                    experiment.ExperimentParameters   = expParam;

                    var artefacts = form["expArtefacts"];
                    foreach (string x in artefacts)
                    {
                        var artefactName = x.Trim();
                        var expArtefact  = await _context.Artefact.
                                           FirstOrDefaultAsync(m => m.Name == artefactName);

                        var         artefactID = expArtefact.Id;
                        ExpArtefact exp        = new ExpArtefact();
                        exp.ExperimentId = expID;
                        exp.ArtefactId   = artefactID;
                        exp.Experiment   = experiment;
                        exp.Artefact     = expArtefact;
                        experiment.ExpArtefacts.Add(exp);
                    }

                    var judges = form["expJudges"];
                    foreach (string x in judges)
                    {
                        var judgeName = x.Trim();
                        var judge     = await _context.Judge.
                                        FirstOrDefaultAsync(m => m.Name == judgeName);

                        var      judgeID = judge.Id;
                        ExpJudge exp     = new ExpJudge();
                        exp.ExperimentId = expID;
                        exp.JudgeLoginId = judge.LoginId;
                        exp.Experiment   = experiment;
                        exp.Judge        = judge;
                        experiment.ExpJudges.Add(exp);
                    }
                    _context.Update(experiment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExperimentExists(experiment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(experiment));
        }