Exemplo n.º 1
0
        public static bool AddNewEntry(DbDirectoryEntry newEntryToAdd, out AddDirectoryEntryFailReason result)
        {
            DbDirectoryEntry possiblyExistingEntry = GetEntryByName(newEntryToAdd.Name);

            if (possiblyExistingEntry != null)
            {
                result = AddDirectoryEntryFailReason.allreadyExistsDuplicateName;
                return(false);
            }

            possiblyExistingEntry = GetUserByTelephone(newEntryToAdd.TelephoneNumber);
            if (possiblyExistingEntry != null)
            {
                result = AddDirectoryEntryFailReason.allreadyExistsDuplicatePhoneNumber;
                return(false);
            }

            var newid = Directory.Max(x => x.Pkid);

            newEntryToAdd.Pkid = newid;
            Directory.Add(newEntryToAdd);

            result = AddDirectoryEntryFailReason.noErrorEntryAdded;
            return(true);
        }
Exemplo n.º 2
0
        public static bool DeleteEntryById(int id)
        {
            DbDirectoryEntry userToRemove = GetEntryById(id);

            if (userToRemove == null)
            {
                return(false);
            }
            Directory.Remove(userToRemove);
            return(true);
        }
Exemplo n.º 3
0
        public static bool UpdateEntry(DbDirectoryEntry userToUpdate)
        {
            var existingId = userToUpdate.Pkid;
            DbDirectoryEntry existingUser = GetEntryById(existingId);

            if (existingUser == null)
            {
                return(false);
            }
            Directory.Remove(existingUser); //NOTE: this is only until we build a read DB!!! DO NOT DO THIS IN PROD
            Directory.Add(userToUpdate);
            return(true);
        }