public Task AddOrganization(ProfileOrganizationViewModel profileOrganizationViewModel) { return(Task.Run(() => { _context.ProfileOrganizations.Add(profileOrganizationViewModel); })); }
public async Task <IActionResult> SetProfileOrganization(string contactId, ProfileOrganizationViewModel profileOrganizationViewModel) { if (contactId == Guid.Empty.ToString()) { return(BadRequest()); } if (contactId != profileOrganizationViewModel.ContactId) { return(BadRequest()); } var profile = await _UnitOfWork.ContactRepository.GetOrganization(contactId); if (profile == null) { await _UnitOfWork.ContactRepository.AddOrganization(profileOrganizationViewModel); } else { await _UnitOfWork.ContactRepository.UpdateOrganization(profileOrganizationViewModel); } return(Ok(profileOrganizationViewModel)); }
public Task UpdateOrganization(ProfileOrganizationViewModel profileOrganizationViewModel) { return(Task.Run(() => { var current = _context.ProfileOrganizations.FirstOrDefault(o => o.Id == profileOrganizationViewModel.Id); current.ManagerId = profileOrganizationViewModel.ManagerId; current.OrganizationId = profileOrganizationViewModel.OrganizationId; current.TeamId = profileOrganizationViewModel.TeamId; _context.SaveChange(); })); }
public Task <ProfileOrganizationViewModel> GetOrganization(string contactId) { return(Task.Run(() => { var o = _context.ProfileOrganizations.FirstOrDefault(c => c.ContactId == contactId); if (o != null) { var vm = new ProfileOrganizationViewModel(o); vm.Organization = _context.Organizations.FirstOrDefault(o => o.Id == vm.OrganizationId); vm.Team = _context.Teams.FirstOrDefault(t => t.Id == vm.TeamId); return vm; } else { return default; } })); }