public int Create(ServiceDescription_User serviceDescription_User) { _serviceDescription_UserRepository.Create(serviceDescription_User); var count = _serviceDescription_UserRepository.SaveChanges(); var user = _userRepository.Get(serviceDescription_User.IdSharedUser); var invitationSecurity = Guid.NewGuid(); _eventDispatcher.Dispatch(new SendInvitationEmailEvent(user.Email, invitationSecurity)); return(count); }
public void ShareServiceDescriptionWithUser(int idServiceDescription, int idUserToShare) { var notYetShared = _serviceDescription_UserRepository.GetAllBySharedUser(idUserToShare).Count(x => x.IdServiceDescription == idServiceDescription) == 0; if (notYetShared) { var serviceDescription_User = new ServiceDescription_User { IdServiceDescription = idServiceDescription, IdSharedUser = idUserToShare }; _serviceDescription_UserRepository.Create(serviceDescription_User); _serviceDescription_UserRepository.SaveChanges(); } }
public void AcceptInvitationForExistingUser(ShareInvitation shareInvitation, User user) { var shareInvitations = _shareInvitationRepository.GetAll() .Where(x => x.Email == shareInvitation.Email.ToLower() && x.InvitationStatus == InvitationStatusEnum.Invited).ToList(); user.ServiceDescription_Users = new List <ServiceDescription_User>(); foreach (var item in shareInvitations) { //Update the invitation status to Accepted item.InvitationStatus = InvitationStatusEnum.Accepted; //Update the entity with the new invitation status in the EF context _shareInvitationRepository.Update(item); //Get the service description according to the service description id in the input parameters var serviceDescription = _serviceDescriptionRepository.GetComplete(item.IdServiceDescription); //Generate the graph (original) for the service description var graphJson = _graphService.CreateGraphData(serviceDescription.Id, serviceDescription.ServiceName, serviceDescription.WsdlInterfaces); //Generate the service description for the (invited) shared user var serviceDescription_User = new ServiceDescription_User { IdServiceDescription = item.IdServiceDescription, IdSharedUser = user.Id }; //Add the link between the (invited) shared user and the service description _serviceDescription_UserRepository.Create(serviceDescription_User); } //Update the (invited) shared user in the database via the EF context _serviceDescription_UserRepository.SaveChanges(); //Save the updated invitation, with new status, in the database via the EF context _shareInvitationRepository.SaveChanges(); }
public int Update(ServiceDescription_User serviceDescription_User) { _serviceDescription_UserRepository.Update(serviceDescription_User); return(_serviceDescription_UserRepository.SaveChanges()); }
public int Remove(ServiceDescription_User serviceDescription_User) { _serviceDescription_UserRepository.Remove(serviceDescription_User.Id); return(_serviceDescription_UserRepository.SaveChanges()); }
public void AcceptInvitationForNewUser(ShareInvitation shareInvitation, User newUser) { var shareInvitations = _shareInvitationRepository.GetAll() .Where(x => x.Email == shareInvitation.Email.ToLower() && x.InvitationStatus == InvitationStatusEnum.Invited).ToList(); newUser.ServiceDescription_Users = new List <ServiceDescription_User>(); foreach (var invitation in shareInvitations) { //Update the invitation status to Accepted invitation.InvitationStatus = InvitationStatusEnum.Accepted; //Update the entity with the new invitation status in the EF context _shareInvitationRepository.Update(invitation); var idServiceDescription = invitation.IdServiceDescription; //Generate the service description for the (invited) shared user var serviceDescription_User = new ServiceDescription_User { IdServiceDescription = idServiceDescription }; //Add the link between the (invited) shared user and the service description newUser.ServiceDescription_Users.Add(serviceDescription_User); var ontologiesUsedByServiceDescription = _serviceDescription_OntologyRepository.GetAll().Where(x => x.IdServiceDescription == idServiceDescription); var ontologiesSharedByOpenedInProject = _shareInvitation_OntologyRepository.GetAll().Where(x => x.IdShareInvitation == invitation.Id); newUser.Ontology_Users = new List <Ontology_User>(); foreach (var idOntology in ontologiesUsedByServiceDescription.Select(x => x.IdOntology).ToList()) { if (!newUser.Ontology_Users.Any(x => x.IdOntology == idOntology)) { newUser.Ontology_Users.Add(new Ontology_User { IdOntology = idOntology }); } } foreach (var idOntology in ontologiesSharedByOpenedInProject.Select(x => x.IdOntology).ToList()) { if (!newUser.Ontology_Users.Any(x => x.IdOntology == idOntology)) { newUser.Ontology_Users.Add(new Ontology_User { IdOntology = idOntology }); } } } //Hash the password for the invited user newUser.Password = HashHelper.GetHash(newUser.Password); //Create the the (invited) shared user in the EF context _userRepository.Create(newUser); //Save the (invited) shared user in the database via the EF context _userRepository.SaveChanges(); //Save the updated invitation, with new status, in the database via the EF context _shareInvitationRepository.SaveChanges(); }