예제 #1
0
        public async Task <ActionResult> Create([FromBody] judge judgeObject)
        {
            if (judgeObject.EmailAddress.Length == 0)
            {
                return(BadRequest(new { Message = "Judge record cannot be created. Email is missing." }));
            }
            else if (judgeObject.JudgeName.Length == 0)
            {
                return(BadRequest(new { Message = "Judge record cannot be created. Judge Name is missing." }));
            }
            else if (judgeObject.AICupperAccountID == null)
            {
                return(BadRequest(new { Message = "Judge record cannot be created. AICUPPER Account is missing." }));
            }
            else
            {
                try {
                    _context.Add(judgeObject);
                    await Task.Run(() => _context.SaveChangesAsync());

                    return(Accepted(new { Message = "Judge record successfully created" }));
                } catch (Exception ex) {
                    return(StatusCode(500));
                }
            }
        }
예제 #2
0
        public Judge GetJudgesData(int judgeId)
        {
            try
            {
                judge user = context.judges.FirstOrDefault(x => x.JudgeId == judgeId);
                if (user != null)
                {
                    Judge dashboardUser = new Judge {
                        JudgeId = user.JudgeId, EmailId = user.EmailId, Name = user.Name, AssignedIdeas = new List <Idea>()
                    };
                    List <IdeaAssignment_Result> result = context.IdeaAssignment(judgeId, 12, 3).ToList();
                    foreach (IdeaAssignment_Result item in result)
                    {
                        dashboardUser.AssignedIdeas.Add(new Idea {
                            EvaluatedCount = item.EvaluatedCount, IdeaDescription = item.IdeaDescription, IdeaId = item.IdeaId, IdeaName = item.IdeaName
                        });
                    }

                    return(dashboardUser);
                }

                return(null);
            }
            catch (Exception ex)
            {
                // Log here
                return(null);
            }
        }
예제 #3
0
        public int GetLoggedInUser(string email, string password)
        {
            try
            {
                // To Do: store password hashes!!
                judge authenticateUser = context.judges.FirstOrDefault(x => x.EmailId == email && x.Password == password);
                if (authenticateUser != null)
                {
                    return(authenticateUser.JudgeId);
                }

                return(-1);
            }
            catch (Exception ex)
            {
                // Log Errror here
                return(-1);
            }
        }
예제 #4
0
        public async Task <IActionResult> Update(int id, [FromBody] judge judge)
        {
            if (id <= 0)
            {
                throw new KeyNotFoundException($"Invalid id: {id}.");
            }

            if (id != judge.JudgeID)
            {
                return(NotFound(new { Message = $"Judge id: {id} does not match given data, id: {judge.JudgeID}." }));
            }

            try
            {
                _context.Update(judge);
                await _context.SaveChangesAsync();

                return(Accepted(new { Message = $"Judge record successfully updated id: {id}" }));
            }
            catch (DbUpdateConcurrencyException)
            {
                return(StatusCode(500));
            }
        }