public async Task <ActionResult> PostCandidate([FromForm] CandidateAddViewModel candidate) { var a = candidate; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (candidate.ExamId > 0) { if (candidate.TC != null && candidate.Image != null) { string NewImageName = Guid.NewGuid().ToString() + "_" + candidate.Image.FileName; string NewImagePath = Path.Combine("Images", NewImageName); string image = Path.Combine(_hostEnv.WebRootPath, NewImagePath); candidate.Image.CopyTo(new FileStream(image, FileMode.Create)); string NewFileName = Guid.NewGuid().ToString() + "_" + candidate.TC.FileName; string NewFilePath = Path.Combine("Files", NewFileName); string file = Path.Combine(_hostEnv.WebRootPath, NewFilePath); candidate.Image.CopyTo(new FileStream(file, FileMode.Create)); Candidate candidateToPost = _mapper.Map <Candidate>(candidate); candidateToPost.ImagePath = NewImagePath; candidateToPost.TCPath = NewFilePath; _repo.Add(candidateToPost); var save = await _repo.SaveAsync(candidateToPost); var rooms = await _room.GetT(); foreach (var room in rooms) { if (_roomCandidateRepo.CountCandidatesInRoom(room.RoomId, candidate.ExamId) < room.Capacity) { RoomCandidate rc = new RoomCandidate { RoomId = room.RoomId, ExamId = candidate.ExamId, CandidateId = candidateToPost.CandidateId }; _seat.Add(rc); await _seat.SaveAsync(rc); candidateToPost.Exams = null; rc.Room.RoomCandidates = null; return(Ok(rc)); } } return(Ok(candidateToPost)); } } return(BadRequest()); }
public async Task <IEnumerable <Room> > GetRooms() { //return await _repo.GetT(); var rooms = await _repo.GetT(); foreach (var room in rooms) { room.ExamCenter = await _centerRepo.GetTById(room.CenterId); room.ExamCenter.Rooms = null; } return(rooms); }
public async Task <IEnumerable <Exam> > GetExams() { List <Exam> examsToReturn = new List <Exam>(); var exams = await _repo.GetT(); foreach (var exam in exams) { var session = await _sessionRepo.GetTById(exam.SessionId); session.Exams = null; exam.Session = session; examsToReturn.Add(exam); } return(examsToReturn); }
public async Task <IEnumerable <Subject> > GetSubjects() { return(await _repo.GetT()); }
public async Task <IEnumerable <SubjectWiseResult> > GetResults() { return(await _repo.GetT()); }
public async Task <IEnumerable <ExamCenter> > GetCenters() { return(await _repo.GetT()); }
public async Task <IEnumerable <StanderdClass> > GetStandards() { return(await _repo.GetT()); }
public async Task <IEnumerable <Candidate> > GetCandidates() { return(await _repo.GetT()); }
public async Task <IEnumerable <Session> > Get() { return(await _repo.GetT()); }
public async Task <IEnumerable <Notice> > GetNotices() { return(await _repo.GetT()); }