Esempio n. 1
0
        public object getUserInfo(GetUserId UserId)
        {
            try
            {
                SchoolMainContext db = new ConcreateContext().GetContext(UserId.UserId, UserId.PASSWORD);
                if (db == null)
                {
                    return(new Results()
                    {
                        IsSuccess = false, Message = "Invalid User"
                    });
                }
                object result      = "";
                var    getUserType = db.VW_GET_USER_TYPE.Where(r => r.UserId == UserId.UserId).FirstOrDefault();

                if (getUserType != null)
                {
                    if (getUserType.UserType == "STUDENT")
                    {
                        STUDENTINFO_BUSINESS GetStudobj = new STUDENTINFO_BUSINESS();
                        result = GetStudobj.getStudInfo(int.Parse(getUserType.EmpCode), UserId.UserId, UserId.PASSWORD);
                    }
                    else if (getUserType.UserType == "Alumini")
                    {
                        return(new Results
                        {
                            IsSuccess = true,
                            Message = new InvalidUser()
                            {
                                IsSuccess = true, Result = "Alumini User"
                            }
                        });
                    }
                    else
                    {
                        GetTeacherInfoBusiness GetTeacherobj = new GetTeacherInfoBusiness();
                        result = GetTeacherobj.getTeacherInfo(int.Parse(getUserType.EmpCode), UserId.UserId, UserId.PASSWORD);
                    }
                    return(result);
                }

                return(new Results
                {
                    IsSuccess = false,
                    Message = new InvalidUser()
                    {
                        IsSuccess = false, Result = "User Not Found"
                    }
                });
            }
            catch (Exception ex)
            {
                return(new Results
                {
                    IsSuccess = false,
                    Message = ex.Message
                });
            }
        }
Esempio n. 2
0
        public object getUserInfo(GetUserId UserId)
        {
            try
            {
                object result      = "";
                var    getUserType = db.VW_GET_USER_TYPE.Where(r => r.UserId == UserId.UserId).FirstOrDefault();

                if (getUserType != null)
                {
                    if (getUserType.UserType == "STUDENT")
                    {
                        STUDENTINFO_BUSINESS GetStudobj = new STUDENTINFO_BUSINESS();
                        result = GetStudobj.getStudInfo(int.Parse(getUserType.EmpCode), UserId.UserId);
                    }
                    else if (getUserType.UserType == "Alumini")
                    {
                        return("ALUMINI USER");
                    }
                    else
                    {
                        GetTeacherInfoBusiness GetTeacherobj = new GetTeacherInfoBusiness();
                        result = GetTeacherobj.getTeacherInfo(int.Parse(getUserType.EmpCode), UserId.UserId);
                    }
                    return(result);
                }
                return(new Error()
                {
                    IsError = true, Message = "User Not Found"
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
        public object getUserInfo(GetUserId UserId)
        {
            try
            {
                SchoolMainContext db = new ConcreateContext().GetContext(UserId.UserId, UserId.PASSWORD);
                if (db == null)
                {
                    return(new Results()
                    {
                        IsSuccess = false, Message = "Invalid User"
                    });
                }
                object result      = "";
                var    getUserType = db.VW_GET_USER_TYPE.Where(r => r.UserId == UserId.UserId).FirstOrDefault();

                if (getUserType != null)
                {
                    if (getUserType.UserType == "STUDENT")
                    {
                        STUDENTINFO_BUSINESS GetStudobj = new STUDENTINFO_BUSINESS();
                        result = GetStudobj.getStudInfo(int.Parse(getUserType.EmpCode), UserId.UserId, UserId.PASSWORD);
                        var notificationUnreadCount = GetStudobj.getNotifCount(int.Parse(getUserType.EmpCode), Convert.ToInt16(UserId.UserId), UserId.PASSWORD);
                        if (result != null && result is VW_STUDENT_INFO)
                        {
                            (result as VW_STUDENT_INFO).HomeworkNotificationUnreadCount = (int)notificationUnreadCount;
                            InstituteBusiness Ibl = new InstituteBusiness();
                            var inresult          = Ibl.GetInstituteName(UserId);
                            if (inresult != null && inresult is ResultBirth)
                            {
                                var r = inresult as ResultBirth;
                                var n = r.Result as ViewGetInstituteName;
                                (result as VW_STUDENT_INFO).InstituteName = n.INSTITUTE_NAME;
                            }
                        }
                    }
                    else if (getUserType.UserType == "Alumini")
                    {
                        return(new Results
                        {
                            IsSuccess = true,
                            Message = "Alumini User"
                        });
                    }
                    else
                    {
                        GetTeacherInfoBusiness GetTeacherobj = new GetTeacherInfoBusiness();
                        result = GetTeacherobj.getTeacherInfo(int.Parse(getUserType.EmpCode), UserId.UserId, UserId.PASSWORD);
                        if (result != null && result is VW_EMPLOYEE)
                        {
                            InstituteBusiness Ibl = new InstituteBusiness();
                            var inresult          = Ibl.GetInstituteName(UserId);
                            if (inresult != null && inresult is ResultBirth)
                            {
                                var r = inresult as ResultBirth;
                                var n = r.Result as ViewGetInstituteName;
                                (result as VW_EMPLOYEE).InstituteName = n.INSTITUTE_NAME;
                            }
                        }
                    }
                    return(result);
                }

                return(new Results
                {
                    IsSuccess = false,
                    Message = "User Not Found"
                });
            }
            catch (Exception ex)
            {
                return(new Results
                {
                    IsSuccess = false,
                    Message = ex.Message
                });
            }
        }