Exemplo n.º 1
0
        /// <Add>
        /// Add a new invitation in DataBase. 
        /// </summary>
        /// <param name="user">Set Values in a invitation Class Property and Pass the Object of invitation Class (SocioBoard.Domain.Admin).</param>
        public int Add(Invitation invitation)
        {
            int res = 0;
            try
            {
                //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(invitation);
                        transaction.Commit();

                        res = 1;

                    }//End Using trasaction
                }//End Using session
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }

            return res;
        }
Exemplo n.º 2
0
        /// < Admin Update>
        /// Update a existing admin.
        /// </summary>
        /// <param name="invitation">Set Values in a Invitation Class Property and Pass the Object of Invitation Class.(Domein.Invitation)</param>
        /// <returns>Return integer 1 for true and 0 for false.</returns>
        public  int SetAllInvitationById(Invitation invitation)
        {
            int res = 0;
            //Creates a database connection and opens up a session
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    //After Session creation, start Transaction. 
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        try
                        {
                            // Proceed Sction to update Data.
                            // And Set the reuired paremeters to find the specific values. 

                            res = session.CreateQuery("Update Invitation set FriendEmail =:friendEmail, FriendName =: friendName , InvitationBody=:invitationBody, SenderEmail =:senderEmail, SenderName =:senderName, Status =:status, Subject =:subject  where Id = :id")
                                      .SetParameter("id", invitation.Id)
                                      .SetParameter("friendEmail", invitation.FriendEmail)
                                      .SetParameter("friendName", invitation.FriendName)
                                      .SetParameter("invitationBody", invitation.InvitationBody)
                                      .SetParameter("senderEmail", invitation.SenderEmail)
                                      .SetParameter("senderName", invitation.SenderName)
                                      .SetParameter("status", invitation.Status)
                                      .SetParameter("subject", invitation.Subject)

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

                        }
                    }//End Using trasaction
                }//End Using session
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }

            return res;
        }
Exemplo n.º 3
0
        /// <GetAllInvitationInfo>
        /// Get All Invitation Info
        /// </summary>
        /// <param name="invitation">Set Values in a Invitation Class Property and Pass the Object of Invitation Class.(Domein.Invitation)</param>
        /// <returns>Return a object of Invitation Class with  value of each member in form of List type.(List<Invitation>)</returns>
        public List<Invitation> GetAllInvitationInfo(Invitation invitation)
        {
            List<Invitation> lstInvitation = new List<Invitation>();
            try
            {
                //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 Get Data from Query
                            //Set the parameters to find the specific Data.
                            lstInvitation = session.CreateQuery("from Invitation")
                            .SetParameter("id", invitation.Id)
                            .List<Invitation>().ToList<Invitation>();

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

                        }
                    }// End using transaction
                }//End Using Session
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }

            return lstInvitation;
        }
Exemplo n.º 4
0
        /// <SetInvitationStatusById>
        /// Update Invitation Status By Sender Email and Freiend Email
        /// </summary>
        /// <param name="invitation">Set Values in a Invitation Class Property and Pass the Object of Invitation Class.(Domein.Invitation)</param>
        /// <returns>Return integer 1 for true and 0 for false.</returns>
        public int SetInvitationStatusBySenderEmailFreiendEmail(Invitation invitation)
        {
            int res = 0;
            //Creates a database connection and opens up a session
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    //After Session creation, start Transaction. 
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        try
                        {
                            // Proceed Sction to update Data.
                            // And Set the reuired paremeters to find the specific values. 

                            res = session.CreateQuery("Update Invitation set Status =:status where SenderEmail = :senderEmail and FriendEmail = :friendEmail")
                                      .SetParameter("status", invitation.Status)
                                      .SetParameter("senderEmail", invitation.SenderEmail)
                                      .SetParameter("friendEmail", invitation.FriendEmail)

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

                        }
                    }//End Using trasaction
                }//End Using session
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }

            return res;
        }
        public int AddInvitationInDB(string fname, string lname, string email)
        {
            int res = 0;
            try
            {
               if (Session["LoggedUser"] != null)
                {
                    SocioBoard.Domain.User user = (User)Session["LoggedUser"];


                    MailHelper mailhelper = new MailHelper();
                    string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/FriendInvitation.htm");
                    string html = File.ReadAllText(mailpath);
                    string fromemail = ConfigurationManager.AppSettings["fromemail"];
                    string usernameSend = ConfigurationManager.AppSettings["username"];
                    string host = ConfigurationManager.AppSettings["host"];
                    string port = ConfigurationManager.AppSettings["port"];
                    string pass = ConfigurationManager.AppSettings["password"];
                    string urllogin = "******";
                    //string registrationurl = "http://dev.socioboard.com/Registration.aspx?refid=256f9c69-6b6a-4409-a309-b1f6d1f8e43b";

                    string registrationurl = "http://dev.socioboard.com/Registration.aspx?refid=" + user.Id;

                    string Body = mailhelper.InvitationMailByCloudSponge(html, fname + " " + lname, user.EmailId, "", urllogin, registrationurl);

                    string Subject = "You've been Invited to Socioboard " + email + " Socioboard Account";


                    #region Add Records in Invitation Table
                    Invitation objInvitation = new Invitation();
                    InvitationRepository objInvitationRepository = new InvitationRepository();

                    objInvitation.Id = Guid.NewGuid();
                    objInvitation.InvitationBody = Body;
                    objInvitation.Subject = Subject;
                    objInvitation.FriendEmail = email;
                    objInvitation.SenderEmail = user.EmailId;//"*****@*****.**";
                    objInvitation.FriendName = fname + " " + lname;
                    objInvitation.SenderName = user.UserName;//"Abhaykumar";
                    objInvitation.Status = "0";

                    res = objInvitationRepository.Add(objInvitation);
                    #endregion
                }
                //else
                //{
                //    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Plaese login for this activity!');", true);

                //}

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return res;
        }
Exemplo n.º 6
0
        public int SetInvitationStatusAfterSuccessfulRegistration(string refid,string userEmail)
        {
            int res = 0;
            try
            {

                UserRepository objUserRepository = new UserRepository();

                User user = objUserRepository.getUsersById(Guid.Parse(refid));

                Invitation objInvitation=new Invitation();
                objInvitation.SenderEmail=user.EmailId;
                objInvitation.FriendEmail=userEmail;
                objInvitation.Status = "12";

                InvitationRepository objInvitationRepository = new InvitationRepository();
                res = objInvitationRepository.SetInvitationStatusBySenderEmailFreiendEmail(objInvitation);
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);

                Console.WriteLine(ex.StackTrace);
                //Response.Redirect("Home.aspx");
            }
            return res;
        }