public async Task <ExecutionResult <Guid> > InsertContactProfile(ContactProfileViewModel viewModel) { ContactProfile contactProfile = _mapper.Map <ContactProfileViewModel, ContactProfile>(viewModel); contactProfile.ContactProfileId = Guid.NewGuid(); return(await _iContactProfileRepository.InsertContactProfile(contactProfile)); }
public ContactProfilePage() { var userService = App.Kernel.Get <IUserService>(); var profileService = App.Kernel.Get <IProfileService>(); var audioService = App.Kernel.Get <IAudioService>(); var playerService = App.Kernel.Get <PlayerService>(); InitializeComponent(); BindingContext = new ContactProfileViewModel(userService, profileService, audioService, playerService, this); }
public async Task <Result> UpdateContactProfileAsync(ContactProfileViewModel model) { var data = _iMapper.Map <ContactProfileViewModel, ContactProfile>(model); var saveChange = await _iContactProfileRepository.UpdateContactProfileAsync(data); if (saveChange > 0) { return(Result.Ok(MessageHelper.Update)); } else { return(Result.Fail(MessageHelper.UpdateFail)); } }
public ActionResult Index() { var currentProfileId = UnitOfWork.ProfileRepository.GetProfileId(User.Identity.GetUserId()); // Hämtar en dictionary med alla användarens kontakter och kategorier var acceptedContactsAndCategories = UnitOfWork.ContactRepository.FindContactsAndCategories(currentProfileId); // Hämtar obesvarade kontaktförfrågningar var pendingContactIds = UnitOfWork.ContactRepository.FindContactIds(currentProfileId, false); var profilesContactsPending = UnitOfWork.ProfileRepository.FindProfiles(pendingContactIds); var listOfProfileContactViewModel = new List <ContactProfileViewModel>(); var profilesIndexViewModelContactsPending = new ProfilesIndexViewModel(); // Itererar igenom kontakter foreach (var item in acceptedContactsAndCategories) { // Om kontakten är aktiv, läggs den till en lista if (item.Key.Active == true) { var profileContactViewModel = new ContactProfileViewModel(item.Key, item.Value); listOfProfileContactViewModel.Add(profileContactViewModel); } } // Itererar igenom förfrågningar foreach (var model in profilesContactsPending) { if (model.Active == true) { var profileIndexViewModelPending = new ProfileIndexViewModel(model); profilesIndexViewModelContactsPending.Profiles.Add(profileIndexViewModelPending); } } // Skapar en viewmodel med både kontaktförfrågningar och kontakter var allContacts = new ContactsViewModel(listOfProfileContactViewModel, profilesIndexViewModelContactsPending); return(View(allContacts)); }
public async Task <Result> InsertContactProfileAsync(ContactProfileViewModel model) { try { var data = _iMapper.Map <ContactProfileViewModel, ContactProfile>(model); var saveChange = await _iContactProfileRepository.InsertContactProfileAsync(data); if (saveChange > 0) { return(Result.Ok(MessageHelper.Save)); } else { return(Result.Fail(MessageHelper.SaveFail)); } } catch (Exception ex) { throw; } }
public async Task <int> InsertOrUpdatetContactProfileAsync(ContactProfileViewModel model) { var data = _iMapper.Map <ContactProfileViewModel, ContactProfile>(model); return(await _iContactProfileRepository.InsertOrUpdatetContactProfileAsync(data)); }