Beispiel #1
0
        public List <AppFile> GetFiles(int FileType, int FileCategory)
        {
            List <AppFile> files = null;

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    if (FileType != 0 && FileCategory != 0)
                    {
                        using (RepsistoryEF <AppFile> _o = new RepsistoryEF <AppFile>())
                        {
                            files = _o.GetListBySelector(x => x.FileType.Equals(FileType) && x.FileCategory.Equals(FileCategory)).ToList();
                        }
                    }

                    trans.Complete();
                    return(files);
                }
                catch (Exception ex)
                {
                    trans.Dispose();
                    throw ex;
                }
                finally
                {
                    trans.Dispose();
                }
            }
        }
Beispiel #2
0
        public UserRegister GetUserInfo(int UserID)
        {
            UserRegister user = null;

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    if (UserID != 0)
                    {
                        using (RepsistoryEF <UserRegister> _o = new RepsistoryEF <UserRegister>())
                        {
                            user = _o.GetListBySelector(x => x.RegistrationID.Equals(UserID)).FirstOrDefault();
                        }
                    }

                    trans.Complete();
                    return(user);
                }
                catch (Exception ex)
                {
                    trans.Dispose();
                    throw ex;
                }
                finally
                {
                    trans.Dispose();
                }
            }
        }
Beispiel #3
0
        public ReturnValues ChangePassword(ChangeUserPassword obj)
        {
            try
            {
                ReturnValues result = null;
                if (obj != null)
                {
                    using (RepsistoryEF <UserRegister> _o = new RepsistoryEF <UserRegister>())
                    {
                        var resultValue = _o.GetListBySelector(z => z.RegistrationID == obj.RegistrationID).FirstOrDefault();

                        if (resultValue != null)
                        {
                            if (resultValue.Password == obj.OldPassword)
                            {
                                resultValue.Password = obj.NewPassword;
                                _o.Update(resultValue);
                                result = new ReturnValues
                                {
                                    Success = "Password Changed Successfully",
                                    Source  = resultValue.RegistrationID.ToString(),
                                };
                            }
                            else
                            {
                                result = new ReturnValues
                                {
                                    Success = "Old password is not correct.<br/>Please try again.",
                                    Source  = resultValue.RegistrationID.ToString(),
                                };
                            }
                        }
                        else
                        {
                            result = new ReturnValues
                            {
                                Success = "Password could not be changed.",
                                Source  = "0",
                            };
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                ReturnValues objex = new ReturnValues
                {
                    Failure = ex.Message,
                };
                throw ex;
            }
            finally
            {
            }
        }
Beispiel #4
0
 public ReturnValues SaveUserFile(AppFile obj)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             ReturnValues ret = null;
             using (RepsistoryEF <AppFile> _o = new RepsistoryEF <AppFile>())
             {
                 obj.IsDownloaded = false;
                 obj.Timestamp    = DateTime.Now;
                 var result = _o.Save(obj);
                 if (result != null)
                 {
                     ret = new ReturnValues
                     {
                         Success = "File has been saved successfully.",
                         Source  = "0",
                     };
                 }
                 else
                 {
                     ret = new ReturnValues
                     {
                         Success = "Failed to save",
                         Source  = "0",
                     };
                 }
                 trans.Complete();
             }
             return(ret);
         }
         catch (Exception ex)
         {
             trans.Dispose();
             ReturnValues objex = new ReturnValues
             {
                 Failure = ex.Message,
             };
             throw ex;
         }
         finally
         {
             trans.Dispose();
         }
     }
 }
Beispiel #5
0
        public ReturnValues LoginUser(Login obj)
        {
            try
            {
                ReturnValues result = null;
                using (RepsistoryEF <UserRegister> _o = new RepsistoryEF <UserRegister>())
                {
                    var resultValue = _o.GetListBySelector(z => z.UserName == obj.UserName.Trim() && z.Password == obj.Password.Trim()).FirstOrDefault();

                    if (resultValue != null)
                    {
                        if (obj.GCMId != null && obj.GCMId != string.Empty)
                        {
                            resultValue.GCMId = obj.GCMId;
                            _o.Update(resultValue);
                        }
                        result = new ReturnValues
                        {
                            Success = "Login Successfully",
                            Source  = resultValue.RegistrationID.ToString(),
                        };
                    }
                    else
                    {
                        result = new ReturnValues
                        {
                            Success = "Login Failed, Please enter correct username and password",
                            Source  = "0",
                        };
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                ReturnValues objex = new ReturnValues
                {
                    Failure = ex.Message,
                };
                throw ex;
            }
            finally
            {
            }
        }
Beispiel #6
0
 public ReturnValues AddComment(DiscussionComment obj)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             ReturnValues ret = null;
             using (RepsistoryEF <DiscussionComment> _o = new RepsistoryEF <DiscussionComment>())
             {
                 var result = _o.Save(obj);
                 if (result != null)
                 {
                     ret = new ReturnValues
                     {
                         Success = "Comment posted successfully.",
                         Source  = "0",
                     };
                 }
                 else
                 {
                     ret = new ReturnValues
                     {
                         Success = "Failed to save",
                         Source  = "0",
                     };
                 }
                 trans.Complete();
             }
             return(ret);
         }
         catch (Exception ex)
         {
             trans.Dispose();
             ReturnValues objex = new ReturnValues
             {
                 Failure = ex.Message,
             };
             throw ex;
         }
         finally
         {
             trans.Dispose();
         }
     }
 }
Beispiel #7
0
        public string GetForgotPassword(string email)
        {
            string response = string.Empty;

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    if (!string.IsNullOrEmpty(email))
                    {
                        using (RepsistoryEF <UserRegister> _o = new RepsistoryEF <UserRegister>())
                        {
                            var user = _o.GetListBySelector(x => x.Email.Equals(email)).FirstOrDefault();
                            if (user != null)
                            {
                                reposSendMail objreposSendMail = new reposSendMail();
                                objreposSendMail.contentBody(user, "ForgetPassword");
                                response = "Password has been sent successfully";
                            }
                            else
                            {
                                response = "Email address is not registered.";
                            }
                        }
                    }

                    trans.Complete();
                    return(response);
                }
                catch (Exception ex)
                {
                    trans.Dispose();
                    throw ex;
                }
                finally
                {
                    trans.Dispose();
                }
            }
        }
Beispiel #8
0
        public string SetFileIsDownloaded(bool flag, int appFileId)
        {
            string response = string.Empty;

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    if (appFileId != 0)
                    {
                        using (RepsistoryEF <AppFile> _o = new RepsistoryEF <AppFile>())
                        {
                            var file = _o.GetListBySelector(x => x.AppFileID.Equals(appFileId)).FirstOrDefault();
                            if (file != null)
                            {
                                file.IsDownloaded = flag;
                                _o.Update(file);
                                response = "OK";
                            }
                        }
                    }

                    trans.Complete();
                    return(response);
                }
                catch (Exception ex)
                {
                    trans.Dispose();
                    throw ex;
                }
                finally
                {
                    trans.Dispose();
                }
            }
        }