/// <updateGooglePlusUser> /// Update google pluse user account details. /// </summary> /// <param name="gpaccount">Set Values in a GooglePlusAccount Class Property and Pass the same Object of GooglePlusAccount Class.(Domain.GooglePlusAccount)</param> public void updateGooglePlusUser(Domain.Myfashion.Domain.GooglePlusAccount gpaccount) { //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 google pluse account details session.CreateQuery("Update GooglePlusAccount set GpUserName =:gpusername,AccessToken =:access,RefreshToken=:refreshtoken,GpProfileImage =:gpprofileimage,RefreshToken=:refreshtoken,EmailId=:emailid where GpUserId = :gpuserid and UserId = :userid") .SetParameter("gpusername", gpaccount.GpUserName) .SetParameter("access", gpaccount.AccessToken) .SetParameter("refreshtoken", gpaccount.RefreshToken) .SetParameter("gpprofileimage", gpaccount.GpProfileImage) .SetParameter("emailid", gpaccount.EmailId) .SetParameter("fbuserid", gpaccount.GpUserId) .SetParameter("userid", gpaccount.UserId) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } //End Transaction } //End Session }
/// <getUserDetails> /// Get the details of account by Google plus Id. /// </summary> /// <param name="GpUserId">Id of goole plus account(String)</param> /// <param name="gpaccount">Set Values in a GooglePlusAccount Class Property and Pass the same Object of GooglePlusAccount Class.(Domain.GooglePlusAccount)</param> public Domain.Myfashion.Domain.GooglePlusAccount getUserDetails(string GpUserId) { //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 Account detail by google id. NHibernate.IQuery query = session.CreateQuery("from GooglePlusAccount where GpUserId = :gpuserid"); query.SetParameter("gpuserid", GpUserId); List <Domain.Myfashion.Domain.GooglePlusAccount> lst = new List <Domain.Myfashion.Domain.GooglePlusAccount>(); foreach (Domain.Myfashion.Domain.GooglePlusAccount item in query.Enumerable()) { lst.Add(item); break; } Domain.Myfashion.Domain.GooglePlusAccount fbacc = lst[0]; return(fbacc); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
/// <addGooglePlusUser> /// Add google account of user /// </summary> /// <param name="gpaccount">Set Values in a GooglePlusAccount Class Property and Pass the same Object of GooglePlusAccount Class.(Domain.GooglePlusAccount)</param> public void addGooglePlusUser(Domain.Myfashion.Domain.GooglePlusAccount gpaccount) { //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 new data . session.Save(gpaccount); transaction.Commit(); } //End Transaction } //End Session }
/// <getGooglePlusAccountDetailsById> /// Get the details of Google account By Id. /// </summary> /// <param name="gpuserid">Google Plus user id(string).</param> /// <param name="userId">User id(Guid)</param> /// <returns>Return the object of group where we get all values from object.(Domain.GooglePlusAccount)</returns> public Domain.Myfashion.Domain.GooglePlusAccount getGooglePlusAccountDetailsById(string gpuserid, Guid userId) { //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 get Details of account by user id and Google plus id. NHibernate.IQuery query = session.CreateQuery("from GooglePlusAccount where GpUserId = :gpuserid and UserId=:userId"); query.SetParameter("gpuserid", gpuserid); query.SetParameter("userId", userId); Domain.Myfashion.Domain.GooglePlusAccount result = (Domain.Myfashion.Domain.GooglePlusAccount)query.UniqueResult(); return(result); } //End Transaction } //End Session }