Пример #1
0
 /// <UpdateGroup>
 /// Update group name
 /// </summary>
 /// <param name="group">Set the group name in a Groups Class Property and Pass the same Object of Groups Class.(Domain.Groups)</param>
 public void UpdateGroup(Domain.Myfashion.Domain.Groups group)
 {
     //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 group name.
                 session.CreateQuery("Update Groups set GroupName =:groupname where UserId = :userid")
                 .SetParameter("groupname", group.GroupName)
                 .SetParameter("userid", group.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Transaction
     }     //End Session
 }
Пример #2
0
        /// <getGroupDetailsbyId>
        /// Get the details of Group by user id and group id.
        /// </summary>
        /// <param name="userid">User id (Guid)</param>
        /// <param name="groupname">Id of Group(Guid)</param>
        /// <returns>Return the object of group.(Domein.Group)</returns>
        public Domain.Myfashion.Domain.Groups getGroupDetailsbyId(Guid userid, Guid groupid)
        {
            //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
                    {
                        NHibernate.IQuery query = session.CreateQuery("from Groups where UserId = :userid and Id=:groupname");

                        query.SetParameter("userid", userid);
                        query.SetParameter("groupname", groupid);
                        Domain.Myfashion.Domain.Groups grou = query.UniqueResult <Domain.Myfashion.Domain.Groups>();
                        return(grou);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                } //End Transaction
            }     //End Session
        }
Пример #3
0
 /// <DeleteGroup>
 /// Delete a group of user by profile id , group id and profile id.
 /// </summary>
 /// <param name="group">Set the group name and user id in a Groups Class Property and Pass the same Object of Groups Class.(Domain.Groups)</param>
 /// <returns>Return 1 when Data  is deleted Otherwise retun 0. (int)</returns>
 public int DeleteGroup(Domain.Myfashion.Domain.Groups group)
 {
     //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 delete the group data.
                 NHibernate.IQuery query = session.CreateQuery("delete from Groups where UserId = :userid and GroupName = :name")
                                           .SetParameter("name", group.GroupName)
                                           .SetParameter("userid", group.UserId);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return(isUpdated);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(0);
             }
         } //End Transaction
     }     //End Session
 }
Пример #4
0
 /// <AddGroup>
 /// Add a new group
 /// </summary>
 /// <param name="group">Set Values in a Groups Class Property and Pass the same Object of Groups Class.(Domain.Groups)</param>
 public void AddGroup(Domain.Myfashion.Domain.Groups group)
 {
     //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(group);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
Пример #5
0
 public string GetGroupDetailsByGroupId(string GroupId)
 {
     logger.Error("GetGroupDetailsByGroupId inside function");
     try
     {
         Domain.Myfashion.Domain.Groups objGroups = grouprepo.getGroupName(Guid.Parse(GroupId));
         return(new JavaScriptSerializer().Serialize(objGroups));
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         logger.Error(ex.StackTrace);
         Console.WriteLine(ex.StackTrace);
         return("Something Went Wrong");
     }
 }