public AllianceMembershipStateInfo(AllianceMembershipState state) { _action = state.GetAction(); _requestorOrganization = state.GetRequestorOrganization(); _requestedAlliance = state.GetRequestedAlliance(); _actionDateTime = state.GetActionDateTime(); }
public static OrganizationAccount FindBy(Guid key) { OrganizationAccount organizationAccountFound = new OrganizationAccount(); // ContentStream contentStreamFound = null; using (var db = new FHNWPrototypeDB()) { var result = (from organizationAccount in db.OrganizationAccounts .Include("Organization") //.Include("PartnershipsRequested.Sender.Organization") //.Include("PartnershipsRequested.Receiver.Organization") //.Include("PartnershipsReceived.Sender.Organization") //.Include("PartnershipsReceived.Receiver.Organization") //.Include("AllianceMemberships.AllianceRequested") //.Include("Employees.OrganizationAccount.Organization") //.Include("Employees.User") //.Include("Location") //.Include("Wall.Posts.Author") //.Include("Wall.Posts.Comments.Author") where organizationAccount.Key == key select organizationAccount).FirstOrDefault(); //contentStreamFound = (from cs in db.ContentStreams // .Include("Posts.Author") // .Include("Posts.Comments.Author") // where cs.Owner.ReferenceKey == organizationAccountFound.Key // select cs).FirstOrDefault(); //if (organizationAccountFound != null) //{ // if (contentStreamFound != null) // { // organizationAccountFound.Wall = contentStreamFound; // } // else // { // ContentStream emptyWall = new ContentStream(); // emptyWall.Posts = new List<Post>(); // organizationAccountFound.Wall = emptyWall; // } //} //else //{ // return null; //} organizationAccountFound.Key = result.Key; organizationAccountFound.Name = result.Name; organizationAccountFound.Organization = result.Organization; organizationAccountFound.Description = result.Description; organizationAccountFound.Location = result.Location; organizationAccountFound.PartnershipsReceived = new List<PartnershipStateInfo>(); organizationAccountFound.PartnershipsRequested = new List<PartnershipStateInfo>(); organizationAccountFound.AllianceMemberships = new List<AllianceMembershipStateInfo>(); organizationAccountFound.Wall = new ContentStream(); organizationAccountFound.Wall.Posts = new List<Post>(); return organizationAccountFound; } }
public override void AllowAllianceMembershipRequestTo(OrganizationAccount contactToAllow) { if (CanAllowAllianceMembershipRequestTo(contactToAllow)) { DomainEvents.Raise(new AllianceMembershipAllowedEvent { MembershipAllowedBy = _requestedAlliance, DateTime = DateTime.Now, MembershipAllowedTo = contactToAllow }); } else { throw new InvalidOperationException("Membership cannot be allowed"); } }
public override void CancelAllianceMembershipRequestOf(OrganizationAccount contactToCancel) { if (CanCancelAllianceMembershipRequestOf(contactToCancel)) { DomainEvents.Raise(new AllianceMembershipCancelledEvent { MembershipCancelledBy = _requestedAlliance, DateTime = DateTime.Now, MembershipCancelledTo = contactToCancel }); } else { throw new InvalidOperationException("Membership cannot be cancelled"); } }
public override bool CanAllowAllianceMembershipRequestTo(OrganizationAccount contactToAllow) { // _requestedAlliance = contactToAllow; return true; }
public override bool CanAcceptAllianceMembershipRequestFrom(OrganizationAccount contactToAccept) { //check conditions return true; }
public AllianceMembershipOfferedState(OrganizationAccount thisPerson, IAllianceMembershipRepository repository) { _requestorOrganization = thisPerson; _submitDateTime = DateTime.Now; _repository = repository; }
public override void AcceptAllianceMembershipRequestFrom(OrganizationAccount contactToAccept) { throw new InvalidOperationException("Membership cannot be accepted"); }
public override bool CanOfferAllianceMembershipRequestTo(OrganizationAccount contactToOffer) { return false; }
public static OrganizationAccountViewModel ConvertOrganizationAccountToViewModel(OrganizationAccount organizationAccount) { OrganizationAccountViewModel organizationAccountView = new OrganizationAccountViewModel(); //organizationAccountView.Key = organizationAccount.Key.ToString(); //organizationAccountView.Name = organizationAccount.Name; //organizationAccountView.Description = organizationAccount.Description; organizationAccountView.Profile = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=organizationAccount.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.OrganizationAccount }, FullName=organizationAccount.Name , Description1= organizationAccount.Organization.Name , Description2= organizationAccount.Organization.Name }; organizationAccountView.Organization = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=organizationAccount.Organization.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.Organization }, FullName=organizationAccount.Organization.Name, Description1=organizationAccount.Description, Description2=organizationAccount.Organization.Description }; organizationAccountView.Email = organizationAccount.Email; organizationAccountView.Location = new GeoLocationViewModel { Latitude = organizationAccount.Location.Latitude.ToString(), Longitude = organizationAccount.Location.Longitude.ToString() }; organizationAccountView.Partners = new List<CompleteProfileViewModel>(); organizationAccountView.Alliances = new List<CompleteProfileViewModel>(); organizationAccountView.Employees = new List<CompleteProfileViewModel>(); organizationAccountView.Wall = new ContentStreamViewModel(); organizationAccountView.Wall.Posts = new List<PostViewModel>(); if (organizationAccount.Employees != null) { foreach (var subitem in organizationAccount.Employees) { organizationAccountView.Employees.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.UserAccount }, FullName= subitem.User.FirstName + " " + subitem.User.LastName , Description1= subitem.OrganizationAccount.Name , Description2=subitem.OrganizationAccount.Organization.Name }); } } if (organizationAccount.AllianceMemberships.Count>0) { foreach (var subitem in organizationAccount.AllianceMemberships) { organizationAccountView.Alliances.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.AllianceRequested.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.Alliance }, FullName=subitem.AllianceRequested.Name , Description1=subitem.AllianceRequested.Description }); } } if (organizationAccount.PartnershipsReceived.Count>0) { foreach (var subitem in organizationAccount.PartnershipsReceived) { organizationAccountView.Partners.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.Sender.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.OrganizationAccount }, FullName=subitem.Sender.Name , Description1= subitem.Sender.Description }); } } if (organizationAccount.PartnershipsRequested.Count>0) { foreach (var subitem in organizationAccount.PartnershipsRequested) { organizationAccountView.Partners.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.Receiver.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.OrganizationAccount }, FullName= subitem.Receiver.Name, Description1= subitem.Receiver.Description }); } } if (organizationAccount.Wall.Posts.Count>0) { foreach (var post in organizationAccount.Wall.Posts) { PostViewModel thisPost = new PostViewModel(); thisPost.Key = post.Key.ToString(); //postView.AuthorKey = post.Author.ReferenceKey.ToString(); //postView.AuthorName = SecurityRepository.GetCompleteProfile(post.Author.ReferenceKey); var postAuthorProfile = SecurityRepository.GetCompleteProfile(post.Author); thisPost.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = postAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = post.Author.ReferenceType }, FullName = postAuthorProfile.FullName, Description1 = postAuthorProfile.Description1, Description2 = postAuthorProfile.Description2 }; thisPost.Text = post.Text; thisPost.PublishDateTime = post.PublishDateTime; thisPost.Comments = new List<CommentViewModel>(); foreach (var comment in post.Comments) { CommentViewModel thisComment = new CommentViewModel(); thisComment.Key = comment.Key.ToString(); //thisComment.AuthorKey = comment.Author.ReferenceKey.ToString(); //thisComment.AuthorName = SecurityRepository.GetCompleteProfile(comment.Author.ReferenceKey); var commentAuthorProfile = SecurityRepository.GetCompleteProfile(comment.Author); thisComment.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = commentAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = commentAuthorProfile.BasicProfile.ReferenceType }, FullName = commentAuthorProfile.FullName, Description1 = commentAuthorProfile.Description1, Description2 = commentAuthorProfile.Description2 }; thisComment.Text = comment.Text; thisComment.PublishDateTime = comment.PublishDateTime; thisPost.Comments.Add(thisComment); } organizationAccountView.Wall.Posts.Add(thisPost); } } else { organizationAccountView.Wall = new ContentStreamViewModel(); organizationAccountView.Wall.Posts = new List<PostViewModel>(); } return organizationAccountView; }
public override void AllowAllianceMembershipRequestTo(OrganizationAccount contactToAllow) { throw new InvalidOperationException("Membership cannot be allowed again"); }
public override bool CanOfferAllianceMembershipRequestTo(OrganizationAccount contactToOffer) { //check conditions // _requestedAlliance = contactToOffer; return true; }
public override bool CanAcceptAllianceMembershipRequestFrom(OrganizationAccount contactToAccept) { return false; }
public override bool CanCancelAllianceMembershipRequestOf(OrganizationAccount contactToCancel) { return false; }
public static void Save(OrganizationAccount entity) { throw new NotImplementedException(); }
public override void CancelAllianceMembershipRequestOf(OrganizationAccount contactToCancel) { throw new InvalidOperationException("Membership cannot be cancelled before being accepted"); }
public override void OfferAllianceMembershipRequestTo(OrganizationAccount contactToOffer) { throw new InvalidOperationException("Membership cannot be offered again"); }
public override bool CanRejectAllianceMembershipRequestFrom(OrganizationAccount contactToReject) { return true; }
public override void RejectAllianceMembershipRequestFrom(OrganizationAccount contactToReject) { if (CanRejectAllianceMembershipRequestFrom(contactToReject)) { DomainEvents.Raise(new AllianceMembershipRejectedEvent { MembershipRejectedBy = _requestedAlliance, DateTime = DateTime.Now, MembershipRequestedBy = contactToReject }); } else { throw new InvalidOperationException("Membership cannot be rejected"); } }
public static void RegisterNewSystemAccount(string email, string password, bool isCorporateAccount) { if (!UserAlreadyExists(email)) { SystemAccount newAccount = new SystemAccount(); newAccount.Email = email; newAccount.Password = password; //newAccount.Key = Guid.NewGuid(); // newAccount.IsConfirmed = true; Guid newRecordGuid = Guid.NewGuid(); if (isCorporateAccount) { BasicProfile basicProfile = new BasicProfile() { ReferenceKey = newRecordGuid, ReferenceType = AccountType.OrganizationAccount }; // CompleteProfile completeProfile = new CompleteProfile { BasicProfile=basicProfile }; OrganizationAccount newOrganizationAccount = new OrganizationAccount() { Key=newRecordGuid, Name="OrganizationAccount" }; newAccount.Holder = basicProfile ; using (var db = new FHNWPrototypeDB()) { db.BasicProfiles.Add(basicProfile); db.SystemAccounts.Add(newAccount); db.OrganizationAccounts.Add(newOrganizationAccount); db.SaveChanges(); } } else { BasicProfile basicProfile = new BasicProfile() { ReferenceKey = newRecordGuid, ReferenceType = AccountType.UserAccount }; // CompleteProfile completeProfile = new CompleteProfile { BasicProfile=basicProfile }; UserAccount newUserAccount = new UserAccount() { Key=newRecordGuid }; newAccount.Holder = basicProfile ; using (var db = new FHNWPrototypeDB()) { db.BasicProfiles.Add(basicProfile); db.SystemAccounts.Add(newAccount); db.UserAccounts.Add(newUserAccount); db.SaveChanges(); } } // newAccount.IsCorporateAccount = isCorporateAccount; // newAccount.CreationDateTime = DateTime.Now; } }
public override void RejectAllianceMembershipRequestFrom(OrganizationAccount contactToReject) { throw new InvalidOperationException("Membership cannot be rejected twice"); }