예제 #1
0
 public int CreateList(MemoList list, string sessionid)
 {
     HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
     return(dBList.InsertList(new HouseManagerServer.MemoList {
         Title = list.Title, Description = list.Description, Person = person
     }));
 }
예제 #2
0
        public List <House> GetAllHouse(string sessionid)
        {
            List <House> list = new List <House>();

            HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
            List <HouseManagerServer.PersonToHouse> houses = dBPersonToHouse.GetAllHouseForPerson(person.Id);

            foreach (var item in houses)
            {
                HouseManagerServer.House house = dBHouse.GetHouseById(item.HouseId);
                house.Address = dBAddress.GetAddressById(house.Address.Id);
                List <PersonToHouse> people = new List <PersonToHouse>();
                foreach (var personToHouse in dBPersonToHouse.GetAllPersonInHouse(house.Id))
                {
                    people.Add(new PersonToHouse {
                        MoveInDate = personToHouse.MoveInDate, IsOwner = personToHouse.IsOwner, Person = new Person {
                            UserName = personToHouse.Person.UserName, DateOfBirth = personToHouse.Person.DateOfBirth, Email = personToHouse.Person.Email, FirstName = personToHouse.Person.FirstName, LastName = personToHouse.Person.LastName, Phone = personToHouse.Person.LastName
                        }
                    });
                }
                list.Add(new House {
                    People = people, Id = house.Id, InviteCode = house.InviteCode, Name = house.Name, Address = new Address {
                        Id = house.Address.Id, City = house.Address.City, DoorNo = house.Address.DoorNo, FloorNo = house.Address.FloorNo, HouseNo = house.Address.HouseNo, Street = house.Address.Street, ZipCode = house.Address.ZipCode
                    }
                });
            }
            return(list);
        }
예제 #3
0
 public Person GetAccountIfromation(string sessionid)
 {
     HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
     return(new Person {
         DateOfBirth = person.DateOfBirth, Email = person.Email, FirstName = person.FirstName, LastName = person.LastName, Phone = person.Phone, UserName = person.UserName
     });
 }
예제 #4
0
        public bool CreateHouse(House house, string sessionid)
        {
            int addressid = -1;

            try
            {
                addressid = dBAddress.CreateAddress(new HouseManagerServer.Address {
                    ZipCode = house.Address.ZipCode, City = house.Address.City, Street = house.Address.Street, HouseNo = house.Address.HouseNo, FloorNo = house.Address.FloorNo, DoorNo = house.Address.DoorNo
                });
                HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
                string invitecode = (house.Name + DateTime.Now + person.UserName).Replace(" ", string.Empty);
                int    houseid    = dBHouse.InsertHouse(new HouseManagerServer.House {
                    Address = new HouseManagerServer.Address {
                        Id = addressid
                    }, Name = house.Name, InviteCode = invitecode
                });
                dBPersonToHouse.JoinHouse(new HouseManagerServer.PersonToHouse {
                    IsOwner = true, Person = person
                }, houseid);
                return(true);
            }
            catch (Exception)
            {
                throw new Exception(addressid.ToString());
            }
        }
예제 #5
0
 public bool LeaveHouse(House house, string sessionid)
 {
     HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
     return(dBPersonToHouse.LeaveHouse(new HouseManagerServer.PersonToHouse {
         Person = person
     }, house.Id));
 }
예제 #6
0
 public bool SendMessage(ChatMessage message, int houseid, string sessionid)
 {
     HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
     return(dBChat.InsertMessage(new HouseManagerServer.ChatMessage {
         Message = message.Message, SendDate = message.SendDate, Sender = person
     }, houseid));
 }
예제 #7
0
 public bool ChangePassword(string oldpassword, string newpassword, string sessionid)
 {
     HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
     if (oldpassword.Equals(person.PassWord))
     {
         person.PassWord = newpassword;
         return(dBPerson.UpdatePerson(person));
     }
     else
     {
         return(false);
     }
 }
예제 #8
0
 public bool UpdateStatus(Chore chore, string sessionid)
 {
     HouseManagerServer.Chore  ch     = dBChore.GetChoreById(chore.Id);
     HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
     if (ch.Person != null && ch.Person.Id == person.Id)
     {
         return(dBChore.UpdateChoreStatus(new HouseManagerServer.Chore {
             Id = chore.Id, Status = chore.Status
         }));
     }
     else
     {
         return(false);
     }
 }
예제 #9
0
 public bool SetChanges(Person account, string sessionid)
 {
     if (dBPerson.GetPersonByUserName(account.UserName) == null)
     {
         HouseManagerServer.Person person = dBSession.GetSessionBySessionID(sessionid).Person;
         person.UserName = account.UserName;
         person.Phone    = account.Phone;
         person.Email    = account.Email;
         return(dBPerson.UpdatePerson(person));
     }
     else
     {
         return(false);
     }
 }
예제 #10
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));
 }
예제 #11
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);
     }
 }
예제 #12
0
        public string Login(Person person)
        {
            HouseManagerServer.Person user = dBPerson.GetPersonByUserName(person.UserName);
            if (user.PassWord.Equals(person.PassWord))
            {
                string sessionid = (user.UserName + DateTime.Now).Replace(" ", string.Empty);

                if (dBSession.InsertSession(new Session {
                    SessionID = sessionid, Person = user
                }))
                {
                    return(sessionid);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }