public string StudentRegister(Students studentDetails) { string isRegisterSuccess = "false"; try { using (var academyEntity = new ATCACADEMYEntities()) { bool isALreadyRegistered = (from stu in academyEntity.Students where stu.IsActive == true && stu.Email == studentDetails.UserName select stu.StudentID).Any(); if (isALreadyRegistered) { isRegisterSuccess = "false"; } else { Student student = new Student(); student.Email = studentDetails.UserName; student.Password = studentDetails.PassWord; student.StudentName = studentDetails.StudentName; student.CreatedDate = DateTime.Now; student.IsActive = true; academyEntity.Students.Add(student); academyEntity.SaveChanges(); isRegisterSuccess = "true"; } } } catch (Exception ex) { isRegisterSuccess = "dberror"; } return(isRegisterSuccess); }
public int?CheckQuestionAnswers(SubmittedAnswers answerSheet) { int?result = 0; int resultVlue = 0; List <GetQuestionAnswers> questionandanswers = new List <GetQuestionAnswers>(); try { using (var academyEntity = new ATCACADEMYEntities()) { questionandanswers = (from ques in academyEntity.Questions where ques.IsValid == true select new GetQuestionAnswers { QuestionsList = ques.QuestionID, AnswersList = ques.Answer }).ToList(); for (int i = 0; i < questionandanswers.Count; i++) { if (questionandanswers[i].AnswersList == answerSheet.AnswersList[i]) { result += 1; resultVlue += 1; } } int? minusValue = questionandanswers.Count - result; double?modulateValue = minusValue * 0.33; result = result - ((int)modulateValue); int minusValueOne = questionandanswers.Count - resultVlue; double modulateValueOne = minusValueOne * 0.33; resultVlue = resultVlue - ((int)modulateValueOne); Result res = new Result(); res.StudentID = int.Parse(System.Web.HttpContext.Current.Request.Cookies["UserCookie"]["UserId"]); res.QuestionGroupID = answerSheet.QuestionGroupId; res.Marks = resultVlue; res.wronganswers = minusValue; academyEntity.Results.Add(res); academyEntity.SaveChanges(); } } catch (Exception ex) { result = null; } return(result); }
public string AddContactUsValues(ContactFormValues contactForm) { string isContactAdded = string.Empty; try { using (var academyEntity = new ATCACADEMYEntities()) { Contactu contactus = new Contactu(); contactus.ContactName = contactForm.Name; contactus.ContactEmail = contactForm.Email; contactus.ContactPhone = contactForm.Phone; contactus.ContactInformation = contactForm.Info; academyEntity.Contactus.Add(contactus); academyEntity.SaveChanges(); isContactAdded = "saved"; } } catch (Exception ex) { isContactAdded = null; } return(isContactAdded); }