Ejemplo n.º 1
0
        public async Task <IActionResult> ShowQuestion([FromQuery] AnswerDTO ques)
        {
            User user = _helperService.GetUser();

            if (user == null)
            {
                return(Ok(new ErrorDto {
                    StatusCode = StatusCodes.Status401Unauthorized, Message = "Unauthorized"
                }));
            }
            else
            {
                var acc = await _context.AssesmentCandidate.Where(x => (x.AssessmentId == ques.assessmentid) && (x.QuestionId == ques.questionid)).SingleOrDefaultAsync();

                AssesmentCandidate ac = new AssesmentCandidate();
                if (acc == null)
                {
                    ac.AssessmentId = ques.assessmentid;
                    ac.QuestionId   = ques.questionid;
                    ac.Status       = 1;
                    _context.AssesmentCandidate.Add(ac);
                }
                else
                {
                    _context.Entry <AssesmentCandidate>(acc).State = EntityState.Detached;
                    ac.Id = acc.Id;
                    _context.AssesmentCandidate.Attach(ac);
                    ac.Status = 1;
                }
                await _context.SaveChangesAsync();

                return(await Question(ques.questionid, ques.assessmentid));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Evaluvate([FromBody] Evaluate evaluate)
        {
            var Ac = new AssesmentCandidate();

            Ac.Id = evaluate.responseid;
            _context.AssesmentCandidate.Attach(Ac);
            Ac.Rating = evaluate.rating;
            Ac.Notes  = evaluate.notes;
            Ac.Status = 3;
            await _context.SaveChangesAsync();

            _context.Entry <AssesmentCandidate>(Ac).State = EntityState.Detached;

            var ac = await _context.AssesmentCandidate
                     .Where(a => a.Id == evaluate.responseid)
                     .SingleOrDefaultAsync();

            var Assments = await _context.vwCandidateJob
                           .Where(a => a.AssessmentId == ac.AssessmentId)
                           .ToListAsync();

            int resptot = Assments.Count;
            //  var rattot = Assments.GroupBy(o => o.AssessmentId).Select(x => new { total = x.Sum(i => i.Rating) });
            int rattotal = 0;

            foreach (var rat in Assments)
            {
                rattotal += rat.Rating.Value;
            }
            if (rattotal != 0 && resptot != 0)
            {
                var nasmnt = new Assessment();
                nasmnt.Id = ac.AssessmentId;
                _context.Assessment.Attach(nasmnt);
                nasmnt.TotalRating        = rattotal / resptot;
                nasmnt.AssessmentStatusId = 2;
                await _context.SaveChangesAsync();
            }
            return(await Evaluation(ac.AssessmentId));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Candidate> > Assessment(AssesmentCandidate Answer)
        {
            try
            {
                var    file       = Request.Form.Files[0];
                string foldpath   = _helperService.RandomString(8, true);
                string folderName = "Apps\\fmr\\Media\\" + foldpath;
                string dr         = Directory.GetCurrentDirectory();
                string newPath    = Path.Combine(Directory.GetParent(dr).Parent.ToString(), folderName);
                if (!Directory.Exists(newPath))
                {
                    Directory.CreateDirectory(newPath);
                }

                string urlpath  = "https://fmr.logistic-solutions.com/media/" + foldpath + "/";
                string fileName = "";
                if (file.Length > 0)
                {
                    fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
                    string fullPath = Path.Combine(newPath, fileName);
                    using (var stream = new FileStream(fullPath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    Answer.Videofile = foldpath + "/" + fileName;
                    _context.AssesmentCandidate.Add(Answer);
                    await _context.SaveChangesAsync();

                    return(CreatedAtAction("ApplyJob", new { id = Answer.Id }, Answer));
                }
                else
                {
                    return(Ok(new { StatusCode = StatusCodes.Status200OK, message = "No Video File Uploaded.", result = urlpath + fileName }));
                }
            }
            catch (System.Exception ex)
            {
                return(Ok(new { StatusCode = StatusCodes.Status417ExpectationFailed, message = ex.Message }));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Answer(IFormFile file, [FromForm] AnswerDTO answer)
        {
            User user = _helperService.GetUser();

            if (user == null)
            {
                return(Ok(new ErrorDto {
                    StatusCode = StatusCodes.Status401Unauthorized, Message = "Unauthorized"
                }));
            }
            else
            {
                try
                {
                    if (file.Length > 0)
                    {
                        string   fileName = ""; fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
                        FileInfo fi       = new FileInfo(fileName);
                        string   fileN    = _helperService.RandomString(8, true) + fi.Extension;
                        string   strurl   = _helperService.GetMediaUrl(user.UserGuid.ToString()) + "/" + fileN;
                        string   fullPath = Path.Combine(_helperService.GetFilePath(user.UserGuid.ToString()), fileN);
                        using (var stream = new FileStream(fullPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                        }
                        var acc = await _context.AssesmentCandidate.Where(x => (x.AssessmentId == answer.assessmentid) && (x.QuestionId == answer.questionid)).SingleOrDefaultAsync();

                        AssesmentCandidate ac = new AssesmentCandidate();
                        if (acc == null)
                        {
                            ac.Videofile    = fileN;
                            ac.UploadedOn   = DateTime.Now;
                            ac.AssessmentId = answer.assessmentid;
                            ac.QuestionId   = answer.questionid;
                            ac.Status       = 2;
                            _context.Add(ac);
                        }
                        else
                        {
                            _context.Entry <AssesmentCandidate>(acc).State = EntityState.Detached;
                            ac.Id = acc.Id;
                            _context.AssesmentCandidate.Attach(ac);
                            ac.Videofile    = fileN;
                            ac.AssessmentId = answer.assessmentid;
                            ac.QuestionId   = answer.questionid;
                            ac.UploadedOn   = DateTime.Now;
                            ac.Status       = 2;
                        }
                        await _context.SaveChangesAsync();

                        return(await Question(answer.questionid, answer.assessmentid));
                    }
                    else
                    {
                        return(Ok(new { StatusCode = StatusCodes.Status200OK, message = "Error Submitting data.", result = "" }));
                    }
                }
                catch (System.Exception ex)
                {
                    return(Ok(new { StatusCode = StatusCodes.Status417ExpectationFailed, message = ex.Message }));
                }
            }
        }