private async Task DeleteContact(UserContactType contactType) { var userContacts = await this.Context.UserContacts .FirstOrDefaultAsync(uc => uc.UserId == this.Update.UserContext.UserId && uc.Type == contactType); if (userContacts != null) { this.Context.UserContacts.Remove(userContacts); await this.Context.SaveChangesAsync(); } }
public UserContact EditContactById(Guid id, UserContactType type, string value) { var contact = GetContactById(id); if (contact != null) { contact.Type = type; contact.Value = value; Context.SaveChanges(); return(contact); } return(null); }
public UserContact AddContactToUser(Guid userId, UserContactType type, string value, DateTime createDate) { var contact = new UserContact() { Id = Guid.NewGuid(), UserId = userId, Type = type, Value = value, CreateDate = createDate }; Context.UserContacts.Add(contact); Context.SaveChanges(); return(contact); }
public bool AddContact(string currentUserId, User targetUser, UserContactType type) { targetUser = FindUser(targetUser); var contactQuery = from c in _db.Set <UserContact>() where c.UserSourceId == currentUserId && c.UserTargetId == targetUser.Id select c; UserContact contact = contactQuery.FirstOrDefault(); bool success = false; if (contact == null) { _db.Set <UserContact>().Add(new UserContact() { UserContactType = type, UserSourceId = currentUserId, UserTargetId = targetUser.Id }); success = true; } return(success); }
public void AddOrUpdateContact(string currentUserId, User targetUser, UserContactType type) { targetUser = FindUser(targetUser); var contactQuery = from c in _db.Set <UserContact>() where c.UserSourceId == currentUserId && c.UserTargetId == targetUser.Id select c; UserContact contact = contactQuery.FirstOrDefault(); if (contact != null) { contact.UserContactType = type; } else { _db.Set <UserContact>().Add(new UserContact() { UserContactType = type, UserSourceId = currentUserId, UserTargetId = targetUser.Id }); } _db.SaveChanges(); }
public UserContactDTO(User user, UserContactType type) { User = user; Type = type; }
public UserContact(UserContactType type, string value) { Type = type; Value = value; }