Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Package objPkg = new Package();

                if (Request.QueryString["Id"] != null)
                    objPkg.Id = Guid.Parse(Request.QueryString["Id"].ToString());
                else
                    objPkg.Id = Guid.NewGuid();

                objPkg.PackageName = txtPackage.Text;
                objPkg.Pricing =double.Parse(txtPricing.Text);
                objPkg.EntryDate = DateTime.Now;
                objPkg.Status = bool.Parse(ddltatus.SelectedValue);
                if (objPkgRepo.checkPackageExists(objPkg.Id))
                    objPkgRepo.UpdatePackage(objPkg);
                else
                    objPkgRepo.AddPackage(objPkg);
                Response.Redirect("ManagePackage.aspx");
            }
            catch(Exception Err)
            {
                logger.Error(Err.Message);
                Response.Write(Err.StackTrace);
            }
        }
 /// <UpdatePackage>
 /// Update Package
 /// </summary>
 /// <param name="package">Set Values in a Package Class Property and Pass the Object of Package Class.(Domein.Package)</param>
 public void UpdatePackage(Package package)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action, to update data.
                 session.CreateQuery("Update Package set PackageName =:packagename , Pricing=:pricing, Status=:status where Id = :packageid")
                     .SetParameter("packagename", package.PackageName)
                     .SetParameter("pricing", package.Pricing)
                     .SetParameter("status",package.Status)
                     .SetParameter("packageid",package.Id)
                     .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         }//End Transaction
     }//End Session
 }
 public void AddPackage(Package package)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(package);
             transaction.Commit();
         }
     }
 }
 /// <AddPackage>
 /// Add Package
 /// </summary>
 /// <param name="package">Set Values in a Package Class Property and Pass the Object of Package Class.(Domein.Package)</param>
 public void AddPackage(Package package)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save data.
             session.Save(package);
             transaction.Commit();
         }//End Transaction
     }//End Session
 }
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;
        }
        public void UpdatePackage(Package package)
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        session.CreateQuery("Update Package set PackageName =:packagename , Pricing=:pricing, Status=:status where Id = :packageid")
                            .SetParameter("packagename", package.PackageName)
                            .SetParameter("pricing", package.Pricing)
                            .SetParameter("status",package.Status)
                            .SetParameter("packageid",package.Id)
                            .ExecuteUpdate();
                        transaction.Commit();

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        // return 0;
                    }
                }
            }
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = (User)Session["LoggedUser"];

            if (!IsPostBack)
            {

                if (user == null)
                    Response.Redirect("/Default.aspx");
                else
                {

                    #region for You can use only 30 days as Unpaid User

                    if (user.PaymentStatus.ToLower() == "unpaid")
                    {
                        if (!SBUtils.IsUserWorkingDaysValid(user.CreateDate))
                        {
                            //cmposecontainer.Attributes.Add("display", "none");
                            cmposecontainer.Attributes.CssStyle.Add("display", "none");
                            topbtn.Attributes.CssStyle.Add("display", "none");
                        }
                    }
                    #endregion

                    //List<Package> lstPackage = new List<Package>();
                    //PackageRepository packageRepo = new PackageRepository();
                    //lstPackage = packageRepo.getAllPackage();

                    //chkdate = user.CreateDate;
                    //DateTime curDate = DateTime.Now;
                    //TimeSpan ts = curDate - chkdate;
                    //datediff = ts.TotalDays;
                    //if (datediff > 30)
                    //{
                    //    Response.Redirect("Settings/Billing.aspx");
                    //}

                    //UserPackageRelation obj = new UserPackageRelation();
                    //obj.Id = new Guid();
                    //obj.UserId = user.Id;
                    //obj.PackageId = lstPackage[1].Id;
                    //obj.PackageStatus = true;
                    //repo.AddUserPackageRelation(obj);

                    //This Code is used for showing user current package
                    UserPackageRelationRepository repoUserPackageRelationRepository = new UserPackageRelationRepository();
                    List<UserPackageRelation> lstUserPackageRelationRepository = new List<UserPackageRelation>();
                    PackageRepository objPackageRepository = new PackageRepository();
                    Package objPackage = new Package();

                    lstUserPackageRelationRepository = repoUserPackageRelationRepository.getUserPackageRelationByUserId(user);

                    if (lstUserPackageRelationRepository.Count > 0)
                    {
                        objPackage = objPackageRepository.getPackageDetailsbyId(lstUserPackageRelationRepository[0].PackageId);
                    }

                    //if (user.PaymentStatus == "unpaid")
                    //{
                    //    daysremaining.InnerHtml = "free " + objPackage.PackageName + " " + datediff + " Days Remaining";
                    //}
                    //else if (user.PaymentStatus == "paid")
                    //{
                    //    daysremaining.InnerHtml = objPackage.PackageName + " Last" + datediff + " Days";
                    //}

                    //End This Code is used for showing user current package

                    try
                    {
                        //if (Session["IncomingTasks"] != null)
                        //{
                        //    incom_tasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
                        //    incomTasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
                        //}
                        //else
                        //{
                        //    TaskRepository taskRepo = new TaskRepository();
                        //    ArrayList alst = taskRepo.getAllIncompleteTasksOfUser(user.Id);
                        //    Session["IncomingTasks"] = alst.Count;
                        //}

                        TaskRepository taskRepo = new TaskRepository();
                        ArrayList alst = taskRepo.getAllIncompleteTasksOfUser(user.Id);
                        Session["IncomingTasks"] = alst.Count;
                        incom_tasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
                        incomTasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);

                    }
                    catch (Exception es)
                    {
                        logger.Error(es.Message);
                        Console.WriteLine(es.Message);
                    }
                    try
                    {
                        if (Session["CountMessages"] != null)
                        {
                            incom_messages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
                            incomMessages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
                        }
                        else
                        {
                            incom_messages.InnerHtml = "0";
                            incomMessages.InnerHtml = "0";
                        }
                    }
                    catch (Exception sx)
                    {
                        logger.Error(sx.Message);
                        Console.WriteLine(sx.Message);
                    }

                    usernm.InnerHtml = "Hello, <a href=\"../Settings/PersonalSettings.aspx\"> " + user.UserName + "</a> ";
                    if (!string.IsNullOrEmpty(user.ProfileUrl))
                    {
                        //Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                        userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" height=\"100\" width=\"100\"/></a></a>";
                        //userinf.InnerHtml = Datetime;
                        //{
                        //    userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" height=\"100\" width=\"100\"/></a></a>";
                        if (user.TimeZone != null)
                        {
                            Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                            userinf.InnerHtml = Datetime;
                        }
                        //if (user.TimeZone == null)
                        //{
                        //    Datetime = DateTime.Now.ToString();
                        //    userinf.InnerHtml = Datetime;
                        //}
                        else
                        {
                            Datetime = DateTime.Now.ToString();
                            userinf.InnerHtml = Datetime;
                        }
                    }
                    else
                    {
                        //Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                        userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"../Contents/img/blank_img.png\" alt=\"" + user.UserName + "\"/></a>";

                        //userinf.InnerHtml = Datetime;
                        if (user.TimeZone != null)
                        {
                            Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                            userinf.InnerHtml = Datetime;
                        }
                        if (user.TimeZone == null)
                        {
                            Datetime = DateTime.Now.ToString();
                            userinf.InnerHtml = Datetime;
                        }
                    }

                    try
                    {

                        GroupRepository grouprepo = new GroupRepository();
                        List<Groups> lstgroups = grouprepo.getAllGroups(user.Id);
                        string totgroups = string.Empty;
                        if (lstgroups.Count != 0)
                        {
                            foreach (Groups item in lstgroups)
                            {
                                totgroups += "<li><a href=\"../Settings/InviteMember.aspx?q=" + item.Id + "\" id=\"group_" + item.Id + "\"><img src=\"../Contents/img/groups_.png\"  alt=\"\"  style=\" margin-right:5px;\"/>" + item.GroupName + "</a></li>";
                            }
                            inviteRedirect.InnerHtml = totgroups;
                        }
                        if (user.AccountType == "SMALL BUSINESS")
                            tot_acc = 10;
                        else if (user.AccountType == "CORPORATION")
                            tot_acc = 20;
                        else if (user.AccountType == "INDIVIDUAL")
                            tot_acc = 50;
                        profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }