public void AddUserRefreeRelation(User objReferee, User objReference)
        {
            try
            {
                logger.Error("Entered AddUserRefreeRelation");

                UserRefRelation objUserRefRelation = new UserRefRelation();
                UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository();

                objUserRefRelation.Id = Guid.NewGuid();
                objUserRefRelation.RefereeUserId = objReferee.Id;
                objUserRefRelation.ReferenceUserId = objReference.Id;
                objUserRefRelation.ReferenceUserEmail = objReference.EmailId;
                objUserRefRelation.RefereeUserEmail = objReferee.EmailId;
                objUserRefRelation.EntryDate = DateTime.Now;
                objUserRefRelation.Status = "0";

                objUserRefRelationRepository.AddUserRefRelation(objUserRefRelation);

                logger.Error("Coming out of AddUserRefreeRelation");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }
        }
        public int AddUserRefRelation(UserRefRelation userRefRelation)
        {
            int res = 0;
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(userRefRelation);
                        transaction.Commit();

                        res = 1;
                    }
                }
                logger.Error("Coming out of AddUserRefRelation");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
                logger.Error("UserRefRelationRepository>>AddUserRefRelation" + ex.Message);
            }

            return res;
        }
        public  int UpdateUserRefRelation(UserRefRelation userRefRelation)
        {
            int i = 0;
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        try
                        {
                            i = session.CreateQuery("Update UserRefRelation set ReferenceUserId =:referenceUserId, RefereeUserId =: refereeUserId , ReferenceUserEmail=:referenceUserEmail,RefereeUserEmail =:refereeUserEmail,EntryDate =:entryDate  where Id = :id")
                                      .SetParameter("referenceUserId", userRefRelation.ReferenceUserId)
                                      .SetParameter("refereeUserId", userRefRelation.RefereeUserId)
                                      .SetParameter("referenceUserEmail", userRefRelation.ReferenceUserEmail)
                                      .SetParameter("refereeUserEmail", userRefRelation.RefereeUserEmail)
                                      .SetParameter("entryDate", userRefRelation.EntryDate)

                                      .ExecuteUpdate();
                            transaction.Commit();

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }


                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }

            return i;
        }
        public int UpdateStatusById(UserRefRelation userRefRelation)
        {
            int i = 0;
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        try
                        {
                            i = session.CreateQuery("Update UserRefRelation set Status =:status  where Id = :id")
                                      .SetParameter("status", userRefRelation.Status)
                                      .SetParameter("id", userRefRelation.Id)

                                      .ExecuteUpdate();

                            transaction.Commit();

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }


                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }

            return i;
        }
Beispiel #5
0
        /// <summary>
        /// to check user reference and update user expiry , userrefrencerelation status
        /// created by Abhay Kr 5-3-2014
        /// </summary>
        /// <param name="RefereeId"></param>
        /// <returns></returns>
        public bool IsUserReferenceActivated(string RefereeId)
        {
            //testing
            Console.WriteLine("Inside " + RefereeId);

            bool ret = false;
            try
            {
                User objUser = new User();
                Package objPackage=new Package ();
                UserPackageRelation objUserPackageRelation=new UserPackageRelation ();
                UserRepository objUserRepository = new UserRepository();
                UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
                UserRefRelation objUserRefRelation = new UserRefRelation();
                UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository();
                PackageRepository objPackageRepository = new PackageRepository();
                objUserRefRelation.ReferenceUserId = (Guid.Parse(RefereeId));

                //testing
                List<UserRefRelation> check =objUserRefRelationRepository.GetUserRefRelationInfo();
                //testing

                List<UserRefRelation> lstUserRefRelation = objUserRefRelationRepository.GetUserRefRelationInfoByRefreeId(objUserRefRelation);
                if (lstUserRefRelation.Count > 0)
                {
                    if (lstUserRefRelation[0].Status == "0")
                    {
                        objUserRefRelation = lstUserRefRelation[0];
                        objUserRefRelation.Status = "1";
                        objUser = objUserRepository.getUsersById(lstUserRefRelation[0].ReferenceUserId);
                        objUser.ExpiryDate = objUser.ExpiryDate.AddDays(30);
                        objUser.AccountType = "Premium";
                        objPackage = objPackageRepository.getPackageDetails("Premium");

                        objUserPackageRelation.Id=Guid.NewGuid();
                        objUserPackageRelation.UserId=objUser.Id;
                        objUserPackageRelation.PackageId=objPackage.Id;
                        objUserPackageRelation.ModifiedDate=DateTime.Now;
                        objUserPackageRelation.PackageStatus=true;
                        objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);
                        int objUserRepositoryresponse = objUserRepository.UpdateUserExpiryDateById(objUser);
                        int objUserRefRelationRepositoryresponse = objUserRefRelationRepository.UpdateStatusById(objUserRefRelation);
                    }
                }

            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            return ret;
        }
Beispiel #6
0
        /// <summary>
        /// to check user reference and update user expiry , userrefrencerelation status
        /// created by Abhay Kr 5-3-2014
        /// </summary>
        /// <param name="RefereeId"></param>
        /// <returns></returns>
        public bool IsUserReferenceActivated(string RefereeId)
        {
            bool ret = false;
            try
            {
                User objUser = new User();
                UserRepository objUserRepository = new UserRepository();
                UserRefRelation objUserRefRelation = new UserRefRelation();
                UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository();
                objUserRefRelation.ReferenceUserId = (Guid.Parse(RefereeId));
                List<UserRefRelation> lstUserRefRelation = objUserRefRelationRepository.GetUserRefRelationInfoById(objUserRefRelation);
                if (lstUserRefRelation.Count > 0)
                {
                    if (lstUserRefRelation[0].Status == "0")
                    {
                        objUserRefRelation = lstUserRefRelation[0];
                        objUserRefRelation.Status = "1";
                        objUser = objUserRepository.getUsersById(lstUserRefRelation[0].ReferenceUserId);
                        objUser.ExpiryDate = objUser.ExpiryDate.AddDays(30);

                        int objUserRepositoryresponse = objUserRepository.UpdateUserExpiryDateById(objUser);

                        int objUserRefRelationRepositoryresponse = objUserRefRelationRepository.UpdateStatusById(objUserRefRelation);
                    }
                }

            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            return ret;
        }
        public List<UserRefRelation> GetUserRefRelationInfoById(UserRefRelation userRefRelation)
        {
            List<UserRefRelation> lstUserRefRelation = new List<UserRefRelation>();
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        try
                        {
                            lstUserRefRelation = session.CreateQuery("from UserRefRelation u where u.ReferenceUserId =:referenceUserId")
                                .SetParameter("referenceUserId", userRefRelation.ReferenceUserId)
                            .List<UserRefRelation>().ToList<UserRefRelation>();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }

            return lstUserRefRelation;
        }