public async Task <List <GetContactDTO> > GetAll() { var contacts = await _dbContext.Contacts.Select(contact => GetContactDTO.FromContact(contact) ).ToListAsync(); await _dbContext.SaveChangesAsync(); return(contacts); }
public ContactDetailsViewModel MapGetContactDTOToContactDetailsViewModel(GetContactDTO model) { return(new ContactDetailsViewModel { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Phone = model.Phone, Active = (model.Active == true ? "Active" : "Inactive"), Lists = string.Join(',', model.Lists.Select(l => l.Value)) }); }
public ContactViewModel MapGetContactDTOToContactViewModel(GetContactDTO model) { return(new ContactViewModel() { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Phone = model.Phone, Active = model.Active, ListIds = model.Lists.Select(l => l.Key).ToList() }); }
public async Task <GetContactDTO> Get(Guid id) { var contact = await _dbContext.Contacts.FirstOrDefaultAsync(); await _dbContext.SaveChangesAsync(); if (contact == null) { throw new NotFoundException(); } return(GetContactDTO.FromContact(contact)); }
public async Task <IActionResult> Edit([FromServices] IContactService contactService, string id) { var user = await _userService.GetUserAsync(id); ViewBag.AssignedContactIds = await _userService.GetAssignedContactsIds(); GetContactDTO currentContact = null; if (user.ContactId != null && user.ContactId > 0) { currentContact = await contactService.GetContact(user.ContactId.Value); } var model = new EditUserViewModel() { Email = user.Email, FirstName = user.FirstName, Id = user.Id, LastName = user.LastName, PhoneNumber = user.PhoneNumber, UserName = user.UserName, Active = user.LockoutEnd == null ? true : user.LockoutEnd < DateTime.Now, ContactAssign = user.ContactId != null ? "Current" : "" }; if (currentContact == null) { model.HasContact = false; } else { model.HasContact = true; model.CurrentContactEmail = currentContact.Email; model.CurrentContactFullName = currentContact.FirstName + " " + currentContact.LastName; } return(View(model)); }