public Message Update(LOT_Candidate_Exam_Result objUI) { Message msg = null; try { LOT_Candidate_Exam_Result objDb = null; if (objUI.SectionId == Constants.LOT_SECTION_VERBAL_TOEIC_ID || objUI.SectionId == Constants.LOT_SECTION_VERBAL_LEVEL_ID) { objDb = this.GetVerbalResultByCandidateExamID(objUI.CandidateExamId); } else { objDb = this.GetResultByCandidateExamIDAndSectionID(objUI.CandidateExamId, objUI.SectionId); } if (objDb != null) { Update(objUI, objDb, ref msg); } else { msg = new Message(MessageConstants.E0005, MessageType.Error, new CandidateExamDao().GetCandidateName(objUI.LOT_Candidate_Exam) + "'s " + objUI.LOT_Section.SectionName + " mark", objUI.LOT_Candidate_Exam.LOT_Exam.Title + " exam"); } } catch (Exception) { msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
public Message Insert(LOT_Candidate_Exam_Result objUI) { Message msg = null; try { if (!IsDublicateCandidateMark(objUI)) { objUI.CreateDate = System.DateTime.Now; objUI.UpdateDate = System.DateTime.Now; dbContext.LOT_Candidate_Exam_Results.InsertOnSubmit(objUI); dbContext.SubmitChanges(); msg = new Message(MessageConstants.I0001, MessageType.Info, new CandidateExamDao().GetCandidateName(objUI.LOT_Candidate_Exam) + "'s " + objUI.LOT_Section.SectionName + " mark in " + objUI.LOT_Candidate_Exam.LOT_Exam.Title + " exam", "added"); } else { msg = new Message(MessageConstants.E0020, MessageType.Error, new CandidateExamDao().GetCandidateName(objUI.LOT_Candidate_Exam) + "'s " + objUI.LOT_Section.SectionName + " mark", objUI.LOT_Candidate_Exam.LOT_Exam.Title + " exam"); } } catch (Exception) { msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
private bool IsDublicateCandidateMark(LOT_Candidate_Exam_Result objUI) { bool isDublicateName = true; LOT_Candidate_Exam_Result dublicateName = dbContext.LOT_Candidate_Exam_Results.Where(a => a.CandidateExamId.Equals(objUI.CandidateExamId) && a.SectionId.Equals(objUI.SectionId) ).FirstOrDefault<LOT_Candidate_Exam_Result>(); if (dublicateName != null && dublicateName.CandidateExamId == objUI.CandidateExamId && dublicateName.SectionId == objUI.SectionId) { isDublicateName = true; } else { isDublicateName = false; } return isDublicateName; }
private void Update(LOT_Candidate_Exam_Result objUI, LOT_Candidate_Exam_Result objDb, ref Message msg) { if (!IsDBChanged(objUI, objDb)) { objDb.Mark = objUI.Mark; objDb.SectionId = objUI.SectionId; objDb.MarkBy = objUI.MarkBy; objDb.Comment = objUI.Comment; objDb.UpdateDate = DateTime.Now; objDb.UpdatedBy = objUI.UpdatedBy; dbContext.SubmitChanges(); msg = new Message(MessageConstants.I0001, MessageType.Info, new CandidateExamDao().GetCandidateName(objUI.LOT_Candidate_Exam) + "'s " + objUI.LOT_Section.SectionName + " mark in " + objUI.LOT_Candidate_Exam.LOT_Exam.Title + " exam", "updated"); } else { msg = new Message(MessageConstants.E0025, MessageType.Info, new CandidateExamDao().GetCandidateName(objUI.LOT_Candidate_Exam) + "'s " + objUI.LOT_Section.SectionName + " mark in " + objUI.LOT_Candidate_Exam.LOT_Exam.Title + " exam"); } }
private bool IsDBChanged(LOT_Candidate_Exam_Result objUI, LOT_Candidate_Exam_Result objDb) { bool isChannged = true; if (objDb.UpdateDate.ToString() == objUI.UpdateDate.ToString()) { isChannged = false; } return isChannged; }