Exemplo n.º 1
0
        public bool JoinHouse(PersonToHouse personToHouse, int houseid)
        {
            string sql = "insert into PersonToHouse (personid, houseid, moveindate, isowner) values (@personid, @houseid, @moveindate, @isowner)";

            command             = DBConnection.GetDbConn().CreateCommand();
            command.CommandText = sql;
            command.Parameters.Clear();
            SqlParameter personidParam = new SqlParameter("@personid", SqlDbType.Int);

            personidParam.Value = personToHouse.Person.Id;
            SqlParameter houseidParam = new SqlParameter("@houseid", SqlDbType.Int);

            houseidParam.Value = houseid;
            SqlParameter isownerParam = new SqlParameter("@isowner", SqlDbType.TinyInt);

            isownerParam.Value = personToHouse.IsOwner;
            SqlParameter moveindateParam = new SqlParameter("@moveindate", SqlDbType.DateTime);

            moveindateParam.Value = DateTime.Now;
            command.Parameters.Add(moveindateParam);
            command.Parameters.Add(personidParam);
            command.Parameters.Add(houseidParam);
            command.Parameters.Add(isownerParam);
            command.ExecuteNonQuery();
            return(true);
        }
Exemplo n.º 2
0
 public bool JoinHouse(string invitecode, string sessionid)
 {
     HouseManagerServer.Person        person        = dBSession.GetSessionBySessionID(sessionid).Person;
     HouseManagerServer.House         house         = dBHouse.GetHouseByInvitecode(invitecode);
     HouseManagerServer.PersonToHouse personToHouse = dBPersonToHouse.GetPersonToHouseByBothIdMovedOut(person.Id, house.Id);
     if (personToHouse != null)
     {
         return(dBPersonToHouse.Update(new HouseManagerServer.PersonToHouse {
             Person = person
         }, house.Id));
     }
     return(dBPersonToHouse.JoinHouse(new HouseManagerServer.PersonToHouse {
         IsOwner = false, Person = person
     }, house.Id));
 }
Exemplo n.º 3
0
 public bool DeleteHouse(House house, string sessionid)
 {
     HouseManagerServer.Person        person        = dBSession.GetSessionBySessionID(sessionid).Person;
     HouseManagerServer.PersonToHouse personToHouse = dBPersonToHouse.GetPersonToHouseByBothId(person.Id, house.Id);
     HouseManagerServer.House         serverhouse   = dBHouse.GetHouseById(house.Id);
     if (personToHouse.IsOwner)
     {
         dBChore.DeleteChoreByHouseId(serverhouse.Id);
         dBPersonToHouse.DeletePersonToHouseByHouseId(serverhouse.Id);
         dBAddress.DeleteAddress(serverhouse.Address);
         dBChatMessage.DeleteChatMessageByHouseId(serverhouse.Id);
         dBHouse.DeleteHouse(serverhouse);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 4
0
        public bool LeaveHouse(PersonToHouse personToHouse, int houseid)
        {
            string sql = "update PersonToHouse set moveoutdate = @moveoutdate where personid = @personid and houseid = @houseid";

            command             = DBConnection.GetDbConn().CreateCommand();
            command.CommandText = sql;
            command.Parameters.Clear();
            SqlParameter moveoutdateParam = new SqlParameter("@moveoutdate", SqlDbType.DateTime);

            moveoutdateParam.Value = DateTime.Now;
            SqlParameter personidParam = new SqlParameter("@personid", SqlDbType.Int);

            personidParam.Value = personToHouse.Person.Id;
            SqlParameter houseidParam = new SqlParameter("@houseid", SqlDbType.Int);

            houseidParam.Value = houseid;
            command.Parameters.Add(moveoutdateParam);
            command.Parameters.Add(personidParam);
            command.Parameters.Add(houseidParam);
            command.ExecuteNonQuery();
            return(true);
        }