public async Task <CommonResponce> InsertTeacherProfile(TeacherProfileVM TeacherToInsert) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; try { Tblmteacher oTeacher = new Tblmteacher { RegNo = TeacherToInsert.RegNo, Name = TeacherToInsert.Name, Address = TeacherToInsert.Address, Email = TeacherToInsert.Email, ContactNo = TeacherToInsert.ContactNo, EducationalQualification = TeacherToInsert.EducationalQualification, LoginUserId = TeacherToInsert.LoginUserId }; //isValid = await _commonRepository.Insert(_mapper.Map<Tblmstudent>(StudentToInsert)); isValid = await _commonRepository.Insert(oTeacher); result.Stat = isValid; result.StatusMsg = "Teacher added successfully"; } catch { result.Stat = isValid; result.StatusMsg = "Failed to add new teacher"; } return(result); }
public async Task <CommonResponce> CheckDataValidation(TeacherProfileVM TeacherToInsert, bool IsAdd) { CommonResponce result = new CommonResponce { Stat = true, StatusMsg = "" }; Tblmteacher oTeacher = null; if (IsAdd) // check validation while adding a new teacher { oTeacher = await _DBTeacherRepository.GetTeacherByRegNo(TeacherToInsert.RegNo).ConfigureAwait(false); if (oTeacher != null) { result.Stat = false; result.StatusMsg = "Registration No already in use"; } else { oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(TeacherToInsert.Email).ConfigureAwait(false); if (oTeacher != null) { result.Stat = false; result.StatusMsg = "Email Id already in use"; } } } else//check validation while updating a teacher profile { oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(TeacherToInsert.Email).ConfigureAwait(false); if (oTeacher != null) { if (oTeacher.Id != TeacherToInsert.Id)// different teacher with same email id { result.Stat = false; } result.StatusMsg = "Email Id already in use"; } oTeacher = await _DBTeacherRepository.GetTeacherByRegNo(TeacherToInsert.RegNo).ConfigureAwait(false); if (oTeacher != null) // got result { if (TeacherToInsert.Id != oTeacher.Id) // different teacher with same reg no { result.Stat = false; result.StatusMsg = "Registration No already in use"; } else // same teacher found check duplicate email id { oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(TeacherToInsert.Email); if (oTeacher != null) { if (TeacherToInsert.Id != oTeacher.Id) // different teacher with same email id { result.Stat = false; } result.StatusMsg = "Email Id already in use"; } } } } return(result); }