Exemple #1
0
        public async Task <CommonResponce> InsertStudentProfile(StudentProfileVM StudentToInsert)
        {
            CommonResponce result = new CommonResponce {
                Stat = false, StatusMsg = ""
            };
            CommonResponce DataValidationResult = new CommonResponce {
                Stat = false, StatusMsg = ""
            };
            bool        isValid  = false;
            Tblmstudent oStudent = null;

            try
            {
                oStudent = new Tblmstudent
                {
                    RegNo       = StudentToInsert.RegNo,
                    Name        = StudentToInsert.Name,
                    Address     = StudentToInsert.Address,
                    Email       = StudentToInsert.Email,
                    ContactNo   = StudentToInsert.ContactNo,
                    StandardId  = StudentToInsert.StandardId,
                    LoginUserId = StudentToInsert.LoginUserId
                };
                //isValid = await _commonRepository.Insert(_mapper.Map<Tblmstudent>(StudentToInsert));
                isValid = await _commonRepository.Insert(oStudent);

                result.Stat      = isValid;
                result.StatusMsg = "Student added successfully";
            }
            catch { result.Stat = isValid; result.StatusMsg = "Failed to add new student"; }
            return(result);
        }
Exemple #2
0
        public async Task <CommonResponce> CheckDataValidation(StudentProfileVM StudentToInsert, bool IsAdd)
        {
            CommonResponce result = new CommonResponce {
                Stat = true, StatusMsg = ""
            };
            Tblmstudent oStudent = null;

            if (IsAdd)  // check validation while adding a new student
            {
                oStudent = await _DBStudentRepository.GetStudentByRegNo(StudentToInsert.RegNo).ConfigureAwait(false);

                if (oStudent != null)
                {
                    result.Stat = false; result.StatusMsg = "Registration No already in use";
                }
                else
                {
                    oStudent = await _DBStudentRepository.GetStudentByEmailID(StudentToInsert.Email);

                    if (oStudent != null)
                    {
                        result.Stat = false; result.StatusMsg = "Email Id already in use";
                    }
                }
            }
            else  // validation while updating
            {
                oStudent = await _DBStudentRepository.GetStudentByRegNo(StudentToInsert.RegNo).ConfigureAwait(false);

                if (oStudent != null)                      // got result
                {
                    if (StudentToInsert.Id != oStudent.Id) // different student with same reg no
                    {
                        result.Stat = false; result.StatusMsg = "Registration No already in use";
                    }
                    else // same student found check duplicate email id
                    {
                        oStudent = await _DBStudentRepository.GetStudentByEmailID(StudentToInsert.Email);

                        if (oStudent != null)
                        {
                            if (StudentToInsert.Id != oStudent.Id)  // different student with same email id
                            {
                                result.Stat = false;
                            }
                            result.StatusMsg = "Email Id already in use";
                        }
                    }
                }
            }
            return(result);
        }