Example #1
0
        public ActionResult AdminLogin(string username, string password)
        {
            string returnmsg = string.Empty;

            Domain.Socioboard.Domain.Admin objAdmin = new Domain.Socioboard.Domain.Admin();
            string uname = Request.QueryString["username"].ToString();
            string pass  = Request.QueryString["password"].ToString();

            Api.Admin.Admin ApiobjAdmin = new Api.Admin.Admin();
            string          LoginData   = ApiobjAdmin.Login(uname, pass);
            string          str         = LoginData.Replace("\"", string.Empty).Trim();

            if (str != "Not Exist")
            {
                objAdmin = (Domain.Socioboard.Domain.Admin)(new JavaScriptSerializer().Deserialize(LoginData, typeof(Domain.Socioboard.Domain.Admin)));
                FormsAuthentication.SetAuthCookie(objAdmin.UserName, false);
                Session["AdminProfile"] = objAdmin;
                returnmsg = "Admin";
            }
            else
            {
                objAdmin  = null;
                returnmsg = "Invalid Email or Password";
                return(Content(returnmsg));
            }
            return(Content(returnmsg));
        }
Example #2
0
        /// < Admin Update>
        /// Update a existing admin.
        /// </summary>
        /// <param name="user">Set Values in a Admin Class Property and Pass the Object of Admin Class.</param>
        public static void Update(Domain.Socioboard.Domain.Admin user)
        {
            //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 Sction to update Data.
                        // And Set the reuired paremeters to find the specific values. 
                        int i = session.CreateQuery("Update Admin set Image =:profileurl, UserName =: username , TimeZone=:timezone,FirstName =:first,LastName =:last  where Id = :twtuserid")
                                  .SetParameter("twtuserid", user.Id)
                                  .SetParameter("profileurl", user.Image)
                                  .SetParameter("username", user.UserName)
                                  .SetParameter("timezone", user.TimeZone)
                                  .SetParameter("first",user.FirstName)
                                  .SetParameter("last",user.LastName)
                                  .ExecuteUpdate();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);

                    }
                }//End Using trasaction
            }//End Using session
        }
Example #3
0
        /// <GetUserInfo>
        /// Get the all information of existing admin by UserName and Password.
        /// </summary>
        /// <param name="UserName">Admin UserName </param>
        /// <param name="Password">Admin Password</param>
        /// <returns>Return Latest Information of Admin</returns>
        public Domain.Socioboard.Domain.Admin GetUserInfo(string UserName, string Password)
        {
            //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.
                        NHibernate.IQuery query = session.CreateQuery("from Admin u where u.UserName = : email and u.Password= :password");
                        query.SetParameter("email", UserName);
                        query.SetParameter("password", Password);

                        // Get the UniqueResult and return.
                        Domain.Socioboard.Domain.Admin result = (Domain.Socioboard.Domain.Admin)query.UniqueResult();
                        return result;

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return null;
                    }
                }// End using transaction
            }//End Using Session
        }
Example #4
0
        /// <Add>
        /// Add a new admin in DataBase. 
        /// </summary>
        /// <param name="user">Set Values in a Admin Class Property and Pass the Object of Admin Class (Domain.Socioboard.Domain.Admin).</param>
        public static void Add(Domain.Socioboard.Domain.Admin user)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start and open Transaction. 
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    //Proceed action to save data.
                    session.Save(user);
                    transaction.Commit();

                }//End Using trasaction
            }//End Using session
        }
 public ActionResult AdminLogin(string username, string password)
 {
     string returnmsg = string.Empty;
     Domain.Socioboard.Domain.Admin objAdmin = new Domain.Socioboard.Domain.Admin();
     string uname = Request.QueryString["username"].ToString();
     string pass = Request.QueryString["password"].ToString();
     Api.Admin.Admin ApiobjAdmin = new Api.Admin.Admin();
     string LoginData = ApiobjAdmin.Login(uname, pass);
     string str = LoginData.Replace("\"", string.Empty).Trim();
     if (str != "Not Exist")
     {
         objAdmin = (Domain.Socioboard.Domain.Admin)(new JavaScriptSerializer().Deserialize(LoginData, typeof(Domain.Socioboard.Domain.Admin)));
         FormsAuthentication.SetAuthCookie(objAdmin.UserName, false);
         Session["AdminProfile"] = objAdmin;
         returnmsg = "Admin";
     }
     else
     {
         objAdmin = null;
         returnmsg = "Invalid Email or Password";
         return Content(returnmsg);
     }
     return Content(returnmsg);
 }