Beispiel #1
0
        public List <API.LABURNUM.COM.Faculty> GetFacultyByAdvanceSearch(DTO.LABURNUM.COM.FacultyModel model)
        {
            IQueryable <API.LABURNUM.COM.Faculty> iQuery = null;

            //Search By Faculty Id.
            if (model.FacultyId > 0)
            {
                iQuery = this._laburnum.Faculties.Where(x => x.FacultyId == model.FacultyId && x.IsActive == true);
            }

            //Seach By Faculty Name
            if (iQuery != null)
            {
                if (model.FacultyName != null)
                {
                    iQuery = iQuery.Where(x => x.FacultyName.Trim().ToLower().Equals(model.FacultyName.Trim().ToLower()) && x.IsActive == true);
                }
            }
            else
            {
                if (model.FacultyName != null)
                {
                    iQuery = this._laburnum.Faculties.Where(x => x.FacultyName.Trim().ToLower().Equals(model.FacultyName.Trim().ToLower()) && x.IsActive == true);
                }
            }

            List <API.LABURNUM.COM.Faculty> dbFaculties = iQuery.ToList();

            return(dbFaculties);
        }
Beispiel #2
0
 public dynamic DoLogin(DTO.LABURNUM.COM.LoginModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.STUDENT))
         {
             DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel()
             {
                 StudentUserName = model.UserName, StudentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = true
             };
             return(new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel));
         }
         if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.PARENT))
         {
             DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel()
             {
                 ParentUserName = model.UserName, ParentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = false
             };
             return(new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel));
         }
         if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.FACULTY))
         {
             DTO.LABURNUM.COM.FacultyModel facultyModel = new DTO.LABURNUM.COM.FacultyModel()
             {
                 UserName = model.UserName, Password = model.Password, ApiClientModel = model.ApiClientModel
             };
             return(new API.LABURNUM.COM.Controllers.FacultyController().FacultyLogin(facultyModel));
         }
         return(model);
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
 private DTO.LABURNUM.COM.FacultyModel MapCore(API.LABURNUM.COM.Faculty apifaculty)
 {
     DTO.LABURNUM.COM.FacultyModel dtoFaculty = new DTO.LABURNUM.COM.FacultyModel()
     {
         FacultyId        = apifaculty.FacultyId,
         FacultyName      = apifaculty.FacultyName,
         UserName         = apifaculty.UserName,
         Password         = apifaculty.Password,
         ClassId          = apifaculty.ClassId != null ? apifaculty.ClassId : null,
         SectionId        = apifaculty.SectionId != null ? apifaculty.SectionId : null,
         UserTypeId       = apifaculty.UserTypeId,
         IsClassTeacher   = apifaculty.IsClassTeacher,
         UserTypeText     = apifaculty.UserType.Text,
         ClassName        = apifaculty.ClassId != null ? apifaculty.Class.ClassName : "",
         SectionName      = apifaculty.SectionId != null ? apifaculty.Section.SectionName : "",
         IsSubjectTeacher = apifaculty.IsSubjectTeacher,
         SubjectId        = apifaculty.SubjectId != null ? apifaculty.SubjectId : null,
         SubjectName      = apifaculty.SubjectId != null ? apifaculty.Subject.SubjectName : "",
         CreatedOn        = apifaculty.CreatedOn,
         Email            = apifaculty.Email,
         ContactNumber    = apifaculty.ContactNumber,
         Photo            = apifaculty.Photo,
         IsActive         = apifaculty.IsActive,
         LastUpdated      = apifaculty.LastUpdated
     };
     return(dtoFaculty);
 }
Beispiel #4
0
 private long AddValidation(DTO.LABURNUM.COM.FacultyModel model)
 {
     model.FacultyName.TryValidate();
     model.UserName.TryValidate();
     model.Password.TryValidate();
     return(AddFaculty(model));
 }
Beispiel #5
0
 public void UpdateStatus(DTO.LABURNUM.COM.FacultyModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         new FrontEndApi.FacultyApi().UpdateIsActive(model);
     }
 }
Beispiel #6
0
 public DTO.LABURNUM.COM.FacultyModel FacultyLogin(DTO.LABURNUM.COM.FacultyModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         return(new FacultyHelper(new FrontEndApi.FacultyApi().FacultyLogin(model.UserName, model.Password)).MapSingle());
     }
     else
     {
         return(null);
     }
 }
Beispiel #7
0
 public List <DTO.LABURNUM.COM.FacultyModel> SearchFacultyByAdvanceSearch(DTO.LABURNUM.COM.FacultyModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         return(new FacultyHelper(new FrontEndApi.FacultyApi().GetFacultyByAdvanceSearch(model)).Map());
     }
     else
     {
         return(null);
     }
 }
Beispiel #8
0
 public long Add(DTO.LABURNUM.COM.FacultyModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         return(new FrontEndApi.FacultyApi().Add(model));
     }
     else
     {
         return(-1);
     }
 }
Beispiel #9
0
 public DTO.LABURNUM.COM.SessionModel DoLogin(DTO.LABURNUM.COM.LoginModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         DTO.LABURNUM.COM.SessionModel sessionmodel = new DTO.LABURNUM.COM.SessionModel();
         // model.Password = GetEncryptedPassword(model.Password);
         if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.STUDENT))
         {
             DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel()
             {
                 StudentUserName = model.UserName, StudentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = true
             };
             sessionmodel.StudentModel  = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel);
             sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId;
             sessionmodel.LoginBy       = model.LoginBy;
         }
         if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.PARENT))
         {
             DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel()
             {
                 ParentUserName = model.UserName, ParentPassword = model.Password, ApiClientModel = model.ApiClientModel
             };
             sessionmodel.StudentModel  = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel);
             sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId;
             sessionmodel.LoginBy       = model.LoginBy;
         }
         if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.FACULTY))
         {
             DTO.LABURNUM.COM.FacultyModel facultyModel = new DTO.LABURNUM.COM.FacultyModel()
             {
                 UserName = model.UserName, Password = model.Password, ApiClientModel = model.ApiClientModel
             };
             sessionmodel.FacultyModel  = new API.LABURNUM.COM.Controllers.FacultyController().FacultyLogin(facultyModel);
             sessionmodel.LoginByUserId = sessionmodel.FacultyModel.FacultyId;
             sessionmodel.LoginBy       = sessionmodel.FacultyModel.UserTypeId;
         }
         API.LABURNUM.COM.AcademicYearTable acy = new FrontEndApi.AcademicYearTableApi().GetAcademicYearByYear(new Component.Utility().GetISTDateTime().Year);
         sessionmodel.AcademicYear   = acy.AcademicYear;
         sessionmodel.AcademicYearId = acy.AcademicYearTableId;
         sessionmodel.LastLoginAt    = new FrontEndApi.LoginActivityApi().GetLastLogin(sessionmodel.LoginByUserId, sessionmodel.LoginBy);
         DTO.LABURNUM.COM.LoginActivityModel lmodel = new DTO.LABURNUM.COM.LoginActivityModel()
         {
             UserTypeId = sessionmodel.LoginBy, StudentId = sessionmodel.LoginByUserId, ClientId = new FrontEndApi.ApiClientApi().GetClientId(model.ApiClientModel.UserName, model.ApiClientModel.Password)
         };
         sessionmodel.LoginActivityId = new FrontEndApi.LoginActivityApi().Add(lmodel);
         return(sessionmodel);
     }
     else
     {
         return(null);
     }
 }
Beispiel #10
0
 private DTO.LABURNUM.COM.FacultyModel MapCore(API.LABURNUM.COM.Faculty apifaculty)
 {
     DTO.LABURNUM.COM.FacultyModel dtoFaculty = new DTO.LABURNUM.COM.FacultyModel()
     {
         FacultyId   = apifaculty.FacultyId,
         FacultyName = apifaculty.FacultyName,
         UserName    = apifaculty.UserName,
         Password    = apifaculty.Password,
         CreatedOn   = apifaculty.CreatedOn,
         IsActive    = apifaculty.IsActive,
         LastUpdated = apifaculty.LastUpdated
     };
     return(dtoFaculty);
 }
Beispiel #11
0
 private long AddFaculty(DTO.LABURNUM.COM.FacultyModel model)
 {
     API.LABURNUM.COM.Faculty apifaculty = new Faculty()
     {
         FacultyName = model.FacultyName,
         UserName    = model.UserName,
         Password    = model.Password,
         CreatedOn   = System.DateTime.Now,
         IsActive    = true
     };
     this._laburnum.Faculties.Add(apifaculty);
     this._laburnum.SaveChanges();
     return(apifaculty.FacultyId);
 }
Beispiel #12
0
        public void UpdateIsActive(DTO.LABURNUM.COM.FacultyModel model)
        {
            model.FacultyId.TryValidate();
            IQueryable <API.LABURNUM.COM.Faculty> iQuery      = this._laburnum.Faculties.Where(x => x.FacultyId == model.FacultyId && x.IsActive == true);
            List <API.LABURNUM.COM.Faculty>       dbFacutlies = iQuery.ToList();

            if (dbFacutlies.Count == 0)
            {
                throw new Exception(API.LABURNUM.COM.Component.Constants.ERRORMESSAGES.NO_RECORD_FOUND);
            }
            if (dbFacutlies.Count > 1)
            {
                throw new Exception(API.LABURNUM.COM.Component.Constants.ERRORMESSAGES.MORE_THAN_ONE_RECORDFOUND);
            }
            dbFacutlies[0].IsActive    = model.IsActive;
            dbFacutlies[0].LastUpdated = System.DateTime.Now;
            this._laburnum.SaveChanges();
        }
Beispiel #13
0
        public API.LABURNUM.COM.Faculty GetFacultyById(long facultyId)
        {
            DTO.LABURNUM.COM.FacultyModel model = new DTO.LABURNUM.COM.FacultyModel()
            {
                FacultyId = facultyId
            };
            List <API.LABURNUM.COM.Faculty> dbFaculties = GetFacultyByAdvanceSearch(model);

            if (dbFaculties.Count == 0)
            {
                throw new Exception(API.LABURNUM.COM.Component.Constants.ERRORMESSAGES.NO_RECORD_FOUND);
            }
            if (dbFaculties.Count > 1)
            {
                throw new Exception(API.LABURNUM.COM.Component.Constants.ERRORMESSAGES.MORE_THAN_ONE_RECORDFOUND);
            }
            return(dbFaculties[0]);
        }
Beispiel #14
0
        public void Update(DTO.LABURNUM.COM.FacultyModel model)
        {
            model.FacultyId.TryValidate();
            IQueryable <API.LABURNUM.COM.Faculty> iQuery      = this._laburnum.Faculties.Where(x => x.FacultyId == model.FacultyId && x.IsActive == true);
            List <API.LABURNUM.COM.Faculty>       dbFacutlies = iQuery.ToList();

            if (dbFacutlies.Count == 0)
            {
                throw new Exception(API.LABURNUM.COM.Component.Constants.ERRORMESSAGES.NO_RECORD_FOUND);
            }
            if (dbFacutlies.Count > 1)
            {
                throw new Exception(API.LABURNUM.COM.Component.Constants.ERRORMESSAGES.MORE_THAN_ONE_RECORDFOUND);
            }
            if (model.ClassId.GetValueOrDefault() == 0)
            {
                model.ClassId = null;
            }
            if (model.SectionId.GetValueOrDefault() == 0)
            {
                model.SectionId = null;
            }
            if (model.SubjectId.GetValueOrDefault() == 0)
            {
                model.SubjectId = null;
            }

            dbFacutlies[0].FacultyName      = model.FacultyName;
            dbFacutlies[0].UserName         = model.UserName;
            dbFacutlies[0].Password         = model.Password;
            dbFacutlies[0].ClassId          = model.ClassId;
            dbFacutlies[0].SectionId        = model.SectionId;
            dbFacutlies[0].UserTypeId       = model.UserTypeId;
            dbFacutlies[0].IsClassTeacher   = model.IsClassTeacher;
            dbFacutlies[0].IsSubjectTeacher = model.IsSubjectTeacher;
            dbFacutlies[0].SubjectId        = model.SubjectId;
            dbFacutlies[0].Photo            = model.Photo;
            dbFacutlies[0].Email            = model.Email;
            dbFacutlies[0].ContactNumber    = model.ContactNumber;
            dbFacutlies[0].LastUpdated      = new Component.Utility().GetISTDateTime();

            this._laburnum.SaveChanges();
        }
Beispiel #15
0
 public dynamic UpdateFacultyProfile(DTO.LABURNUM.COM.FacultyModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         if (model.FacultyId <= 0)
         {
             return(GetApiResponseModel("Faculty Id Cannnot be Zero or Less Than Zero.", false, null));
         }
         if (model.FacultyId <= 0 || model.NewPassword == null)
         {
             return(GetApiResponseModel("Password Cannnot be Null.", false, null));
         }
         new FrontEndApi.FacultyApi().UpdateProfile(model);
         return(GetApiResponseModel("Profile Updated Successfully.", true, null));
     }
     else
     {
         return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null));
     }
 }
Beispiel #16
0
 public dynamic SearchFacultyByFacultyId(DTO.LABURNUM.COM.FacultyModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         if (model.FacultyId <= 0)
         {
             return(GetApiResponseModel("Faculty Id Cannnot be Zero or Less Than Zero.", true, null));
         }
         List <DTO.LABURNUM.COM.FacultyModel> dbFacutlies = new FacultyHelper(new FrontEndApi.FacultyApi().GetFacultyByAdvanceSearch(model)).Map();
         if (dbFacutlies.Count == 0)
         {
             return(GetApiResponseModel("No Record Found For Given Faculty Id", true, null));
         }
         if (dbFacutlies.Count > 1)
         {
             return(GetApiResponseModel("More Than One Record Found Please Contact Administrator", true, null));
         }
         return(GetApiResponseModel("Successfully Performed.", true, dbFacutlies[0]));
     }
     else
     {
         return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null));
     }
 }
Beispiel #17
0
        private long AddFaculty(DTO.LABURNUM.COM.FacultyModel model)
        {
            if (model.ClassId.GetValueOrDefault() == 0)
            {
                model.ClassId = null;
            }
            if (model.SectionId.GetValueOrDefault() == 0)
            {
                model.SectionId = null;
            }
            if (model.SubjectId.GetValueOrDefault() == 0)
            {
                model.SubjectId = null;
            }

            API.LABURNUM.COM.Faculty apifaculty = new Faculty()
            {
                FacultyName      = model.FacultyName,
                UserName         = model.UserName,
                Password         = model.Password,
                ClassId          = model.ClassId,
                SectionId        = model.SectionId,
                IsClassTeacher   = model.IsClassTeacher,
                UserTypeId       = model.UserTypeId,
                IsSubjectTeacher = model.IsSubjectTeacher,
                SubjectId        = model.SubjectId,
                CreatedOn        = new Component.Utility().GetISTDateTime(),
                IsActive         = true,
                Photo            = model.Photo,
                Email            = model.Email,
                ContactNumber    = model.ContactNumber
            };
            this._laburnum.Faculties.Add(apifaculty);
            this._laburnum.SaveChanges();
            return(apifaculty.FacultyId);
        }
Beispiel #18
0
 public long Add(DTO.LABURNUM.COM.FacultyModel model)
 {
     return(AddValidation(model));
 }
Beispiel #19
0
        public dynamic DoLogin(DTO.LABURNUM.COM.LoginModel model)
        {
            if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
            {
                DTO.LABURNUM.COM.SessionModel sessionmodel = new DTO.LABURNUM.COM.SessionModel();
                //model.Password = GetEncryptedPassword(model.Password);
                try
                {
                    if (model.LoginBy == 0)
                    {
                        return(GetApiResponseModel("Login By Cannot Be Null.", false, null));
                    }
                    if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.STUDENT))
                    {
                        if (model.UserName == "" || model.Password == "")
                        {
                            return(GetApiResponseModel("Student UserName Or Password Cannnot Be Blank.", false, null));
                        }

                        DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel()
                        {
                            StudentUserName = model.UserName, StudentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = true
                        };

                        sessionmodel.StudentModel  = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel);
                        sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId;
                    }
                    if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.PARENT))
                    {
                        if (model.UserName == "" || model.Password == "")
                        {
                            return(GetApiResponseModel("Parent UserName Or Password Cannnot Be Blank.", false, null));
                        }

                        DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel()
                        {
                            ParentUserName = model.UserName, ParentPassword = model.Password, ApiClientModel = model.ApiClientModel
                        };
                        sessionmodel.StudentModel  = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel);
                        sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId;
                    }
                    if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.FACULTY))
                    {
                        if (model.UserName == "" || model.Password == "")
                        {
                            return(GetApiResponseModel("Faculty UserName Or Password Cannnot Be Blank.", false, null));
                        }

                        DTO.LABURNUM.COM.FacultyModel facultyModel = new DTO.LABURNUM.COM.FacultyModel()
                        {
                            UserName = model.UserName, Password = model.Password, ApiClientModel = model.ApiClientModel
                        };
                        sessionmodel.FacultyModel  = new API.LABURNUM.COM.Controllers.FacultyController().FacultyLogin(facultyModel);
                        sessionmodel.LoginByUserId = sessionmodel.FacultyModel.FacultyId;
                    }

                    sessionmodel.LoginBy = model.LoginBy;
                    API.LABURNUM.COM.AcademicYearTable acy = new FrontEndApi.AcademicYearTableApi().GetAcademicYearByYear(new Component.Utility().GetISTDateTime().Year);
                    sessionmodel.AcademicYear   = acy.AcademicYear;
                    sessionmodel.AcademicYearId = acy.AcademicYearTableId;
                    sessionmodel.LastLoginAt    = new FrontEndApi.LoginActivityApi().GetLastLogin(sessionmodel.LoginByUserId, sessionmodel.LoginBy);
                    DTO.LABURNUM.COM.LoginActivityModel lmodel = new DTO.LABURNUM.COM.LoginActivityModel()
                    {
                        UserTypeId = sessionmodel.LoginBy, StudentId = sessionmodel.LoginByUserId, ClientId = new FrontEndApi.ApiClientApi().GetClientId(model.ApiClientModel.UserName, model.ApiClientModel.Password)
                    };
                    sessionmodel.LoginActivityId = new FrontEndApi.LoginActivityApi().Add(lmodel);
                    return(GetApiResponseModel("SuccessFully Performed", true, sessionmodel));
                }
                catch (Exception ex)
                {
                    return(GetApiResponseModel(ex.Message.ToString(), false, null));
                }
            }
            else
            {
                return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null));
            }
        }