public static Candidateviewmodal LoginUser(Candidateviewmodal model) { model.isValidUser = false; model.LoginMessage = "Wrong Username or password "; using (QuizContext cntxt = new QuizContext()) { var q = from can in cntxt.Candidates where can.CandidateName == model.CandidateName && can.Password == model.Password select can; foreach (var element in q) { CandidateLogin cndlog = new CandidateLogin(); cndlog.CandidateId = element.CandidateId; cndlog.LogDate = DateTime.Now; cntxt.CandidateLogins.Add(cndlog); model.isValidUser = true; model.LoginMessage = "Candidate Sucessfully Added"; model.isValidUser = true; model.CandidateId = element.CandidateId; } cntxt.SaveChanges(); } return(model); }
public static Candidateviewmodal RegisterUser(Candidateviewmodal model) { using (QuizContext cntxt = new QuizContext()) { if (!cntxt.Candidates.Any(o => o.CandidateName == model.CandidateName)) { Candidate cndate = new Candidate(); cndate.CandidateName = model.CandidateName; cndate.Password = model.Password; cndate.CandidateEmail = model.EmailID; cndate.AddedDate = DateTime.Now; cntxt.Candidates.Add(cndate); cntxt.SaveChanges(); CandidateLogin cndlog = new CandidateLogin(); cndlog.CandidateId = cndate.CandidateId; cndlog.LogDate = DateTime.Now; cntxt.CandidateLogins.Add(cndlog); cntxt.SaveChanges(); model.isValidUser = true; model.LoginMessage = "Candidate Sucessfully Added"; model.isValidUser = true; model.CandidateId = model.CandidateId; } else { model.isValidUser = false; model.LoginMessage = "User Name Already Used;Try another name "; } } return(model); }
public Candidateviewmodal RegisterUser(Candidateviewmodal model) { return(ExamRepository.RegisterUser(model)); }
public Candidateviewmodal LoginUser(Candidateviewmodal model) { return(ExamRepository.LoginUser(model)); }