Esempio n. 1
0
        public object Confirm([FromBody] ParamLogin userLogin)
        {
            try
            {
                string TeacherBaseUrl = "";
                string StudentBaseUrl = "";

                LoginManager objLogin    = new LoginManager();
                var          logindetail = objLogin.GetLoginDetails(userLogin);
                if (logindetail == null)
                {
                    return new Results()
                           {
                               IsSuccess = false, Message = new InvalidUser()
                               {
                                   IsSuccess = false, Result = "User Name & Password is Incorrect"
                               }
                           }
                }
                ;


                else
                {
                    if (logindetail.UserType == "STUDENT")
                    {
                        STUDENTINFO_BUSINESS StudBL = new STUDENTINFO_BUSINESS();
                        var result = StudBL.getStudLogo(int.Parse(logindetail.EmpCode), Convert.ToInt16(logindetail.UserId), logindetail.Password);

                        var notificationUnreadCount = StudBL.getNotifCount(int.Parse(logindetail.EmpCode), Convert.ToInt16(logindetail.UserId), logindetail.Password);

                        if (result == null)
                        {
                        }
                        else
                        {
                            logindetail.IMAGEPATH = (string)result;
                            logindetail.HomeworkNotificationUnreadCount = (int)notificationUnreadCount;
                        }
                        if (logindetail.UserName.StartsWith("NKV"))
                        {
                            StudentBaseUrl = ConfigurationManager.AppSettings["NkvsBaseUrlStudent"];
                        }
                        else if (logindetail.UserName.StartsWith("SXS"))
                        {
                            StudentBaseUrl = ConfigurationManager.AppSettings["StxavierBaseUrlStudent"];
                        }
                        logindetail.BaseURL = StudentBaseUrl;
                    }
                    else
                    {
                        GetTeacherInfoBusiness TeacherBL = new GetTeacherInfoBusiness();
                        var result = TeacherBL.getTeacherLogo(int.Parse(logindetail.EmpCode), Convert.ToInt16(logindetail.UserId), logindetail.Password);
                        if (result == null)
                        {
                        }
                        else
                        {
                            logindetail.IMAGEPATH = (string)result;
                        }
                        if (logindetail.UserName.StartsWith("NKV"))
                        {
                            TeacherBaseUrl = ConfigurationManager.AppSettings["NkvsBaseUrlTeacher"];
                        }
                        else if (logindetail.UserName.StartsWith("SXS"))
                        {
                            TeacherBaseUrl = ConfigurationManager.AppSettings["StxavierBaseUrlTeacher"];
                        }
                        logindetail.BaseURL = TeacherBaseUrl;
                    }
                    DeviceBusinessLayer objDeviceBl = new DeviceBusinessLayer();

                    ParamDevice PDeviceObj = new ParamDevice();
                    PDeviceObj.UserId     = (int)logindetail.UserId;
                    PDeviceObj.DeviceId   = userLogin.DeviceId;
                    PDeviceObj.DeviceType = userLogin.DeviceType;
                    objDeviceBl.SaveDevice(PDeviceObj, logindetail.Password);

                    logindetail.DeviceId   = userLogin.DeviceId;
                    logindetail.DeviceType = userLogin.DeviceType;

                    return(logindetail);
                }
            }
            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
                });
            }
        }