public object SaveDevice(ParamDevice obj, string Password)
        {
            SchoolMainContext     db    = new ConcreateContext().GetContext(obj.UserId, Password);
            TBLDeviceRegistration objDR = new TBLDeviceRegistration();

            var getUserId = db.VW_DEVICE.Where(r => r.UserId == obj.UserId).FirstOrDefault();

            try
            {
                if (getUserId == null)
                {
                    //save
                    objDR.UserId       = obj.UserId;
                    objDR.DeviceId     = obj.DeviceId;
                    objDR.DeviceType   = obj.DeviceType;
                    objDR.InsertDate   = DateTime.Now;
                    objDR.ModifiedDate = DateTime.Now;
                    objDR.Status       = true;
                    db.TBLDeviceRegistrations.Add(objDR);
                    db.SaveChanges();

                    return("Device Registration Succesfull!");
                }
                else
                {
                    //update
                    TBLDeviceRegistration objdetail = db.TBLDeviceRegistrations.First(r => r.UserId == obj.UserId);

                    objdetail.Id           = getUserId.Id;
                    objdetail.UserId       = getUserId.UserId;
                    objdetail.DeviceId     = obj.DeviceId;
                    objdetail.DeviceType   = obj.DeviceType;
                    objdetail.InsertDate   = getUserId.InsertDate;
                    objdetail.ModifiedDate = DateTime.Now;
                    objdetail.Status       = true;

                    //db.TBLDeviceRegistrations.Add(objdetail);
                    db.SaveChanges();

                    return("Notification Updated successfully");
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return("");
        }
Example #2
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
                });
            }
        }