public static GroupEditView GetGroupEditViewForForUserOnly(ApplicationDbContext db, Guid appUserId) { List <GroupListView> groupListViewsCreatedByUser = GroupViewHelpers.GetGroupListViewsCreatedByUser(db, appUserId); GroupEditView view = new GroupEditView() { GroupListViewsCreatedByUser = groupListViewsCreatedByUser, GroupListViewsRelevantToUser = new List <GroupListView>() }; return(view); }
public static Group CreateGroupFromGroupAddView(ApplicationDbContext db, GroupAddView view, IPrincipal user) { Group group = new Group() { GroupId = Guid.NewGuid(), Name = view.Name, Type = view.Type, VisibilityLevel = view.VisibilityLevel, InviteLevel = view.InviteLevel, AcceptanceLevel = view.AcceptanceLevel, GroupOriginatorAppUserId = AppUserHelpers.GetAppUserIdFromUser(user), GroupOriginatorDateTime = DateTime.Now }; db.Groups.Add(group); db.SaveChanges(); GroupViewHelpers.CreateGroupMembersFromGroupAddView(db, view, group); return(group); }
public static AppUserEditView GetAppUserEditViewForUser(ApplicationDbContext db, AppUser appUserDetails) { Branch branch = BranchHelpers.GetBranch(db, appUserDetails.CurrentBranchId); BranchUser branchUser = BranchUserHelpers.GetBranchUser(db, appUserDetails.AppUserId, appUserDetails.CurrentBranchId); AppUserSettings appUserSettings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserDetails.AppUserId); AppUserEditView view = new AppUserEditView() { AppUserId = appUserDetails.AppUserId, FirstName = appUserDetails.FirstName, LastName = appUserDetails.LastName, EntityStatus = appUserDetails.EntityStatus, PrivacyLevel = appUserDetails.PrivacyLevel, SelectedBranchId = appUserDetails.CurrentBranchId, UserRole = branchUser.UserRole, AppUserSettingsId = appUserSettings.AppUserSettingsId, BranchName = branch.BranchName, BranchBusinessType = branch.BusinessType, BranchAddressLine1 = branch.AddressLine1, BranchAddressLine2 = branch.AddressLine2, BranchAddressLine3 = branch.AddressLine3, BranchAddressTownCity = branch.AddressTownCity, BranchAddressCounty = branch.AddressCounty, BranchAddressPostcode = branch.AddressPostcode, CampaignDashboardMaxDistance = appUserSettings.CampaignDashboardMaxDistance, CampaignDashboardMaxAge = appUserSettings.CampaignDashboardMaxAge, RequiredListingDashboardMaxDistance = appUserSettings.RequiredListingDashboardMaxDistance, RequiredListingDashboardMaxAge = appUserSettings.RequiredListingDashboardMaxAge, AvailableListingDashboardMaxDistance = appUserSettings.AvailableListingDashboardMaxDistance, AvailableListingDashboardMaxAge = appUserSettings.AvailableListingDashboardMaxAge, CampaignDashboardExternalSelectionLevel = appUserSettings.CampaignDashboardExternalSelectionLevel, RequiredListingDashboardExternalSelectionLevel = appUserSettings.RequiredListingDashboardExternalSelectionLevel, AvailableListingDashboardExternalSelectionLevel = appUserSettings.AvailableListingDashboardExternalSelectionLevel, CampaignGeneralInfoDisplayMyUserListings = appUserSettings.CampaignGeneralInfoDisplayMyUserListings, CampaignGeneralInfoDisplayMyBranchListings = appUserSettings.CampaignGeneralInfoDisplayMyBranchListings, CampaignGeneralInfoDisplayMyCompanyListings = appUserSettings.CampaignGeneralInfoDisplayMyCompanyListings, CampaignGeneralInfoDisplayBlockedListings = appUserSettings.CampaignGeneralInfoDisplayBlockedListings, CampaignGeneralInfoMaxDistance = appUserSettings.CampaignGeneralInfoMaxDistance, RequiredListingGeneralInfoDisplayMyUserListings = appUserSettings.RequiredListingGeneralInfoDisplayMyUserListings, RequiredListingGeneralInfoDisplayMyBranchListings = appUserSettings.RequiredListingGeneralInfoDisplayMyBranchListings, RequiredListingGeneralInfoDisplayMyCompanyListings = appUserSettings.RequiredListingGeneralInfoDisplayMyCompanyListings, RequiredListingGeneralInfoDisplayBlockedListings = appUserSettings.RequiredListingGeneralInfoDisplayBlockedListings, RequiredListingGeneralInfoMaxDistance = appUserSettings.RequiredListingGeneralInfoMaxDistance, AvailableListingGeneralInfoDisplayMyUserListings = appUserSettings.AvailableListingGeneralInfoDisplayMyUserListings, AvailableListingGeneralInfoDisplayMyBranchListings = appUserSettings.AvailableListingGeneralInfoDisplayMyBranchListings, AvailableListingGeneralInfoDisplayMyCompanyListings = appUserSettings.AvailableListingGeneralInfoDisplayMyCompanyListings, AvailableListingGeneralInfoDisplayBlockedListings = appUserSettings.AvailableListingGeneralInfoDisplayBlockedListings, AvailableListingGeneralInfoMaxDistance = appUserSettings.AvailableListingGeneralInfoMaxDistance, CampaignManageViewInternalSelectionLevel = appUserSettings.CampaignManageViewInternalSelectionLevel, RequiredListingManageViewInternalSelectionLevel = appUserSettings.RequiredListingManageViewInternalSelectionLevel, AvailableListingManageViewInternalSelectionLevel = appUserSettings.AvailableListingManageViewInternalSelectionLevel, OffersManageViewInternalSelectionLevel = appUserSettings.OffersManageViewInternalSelectionLevel, OffersAcceptedAuthorisationManageViewLevel = appUserSettings.OffersAcceptedAuthorisationManageViewLevel, OffersRejectedAuthorisationManageViewLevel = appUserSettings.OffersRejectedAuthorisationManageViewLevel, OffersReturnedAuthorisationManageViewLevel = appUserSettings.OffersReturnedAuthorisationManageViewLevel, OrdersManageViewInternalSelectionLevel = appUserSettings.OrdersManageViewInternalSelectionLevel, OrdersDespatchedAuthorisationManageViewLevel = appUserSettings.OrdersDespatchedAuthorisationManageViewLevel, OrdersDeliveredAuthorisationManageViewLevel = appUserSettings.OrdersDeliveredAuthorisationManageViewLevel, OrdersCollectedAuthorisationManageViewLevel = appUserSettings.OrdersCollectedAuthorisationManageViewLevel, OrdersClosedAuthorisationManageViewLevel = appUserSettings.OrdersClosedAuthorisationManageViewLevel, CampaignGeneralInfoExternalSelectionLevel = appUserSettings.CampaignGeneralInfoExternalSelectionLevel, RequiredListingGeneralInfoExternalSelectionLevel = appUserSettings.RequiredListingGeneralInfoExternalSelectionLevel, AvailableListingGeneralInfoExternalSelectionLevel = appUserSettings.AvailableListingGeneralInfoExternalSelectionLevel, GroupListViewsForUserOnly = GroupViewHelpers.GetGroupEditViewForForUserOnly(db, appUserDetails.AppUserId), UserFriendListView = FriendViewHelpers.GetFriendViewByType(db, appUserDetails.AppUserId, LevelEnum.User), UserBranchFriendListView = FriendViewHelpers.GetFriendViewByType(db, appUserDetails.AppUserId, LevelEnum.Branch), UserCompanyFriendListView = FriendViewHelpers.GetFriendViewByType(db, appUserDetails.AppUserId, LevelEnum.Company), UserBlockListView = BlockViewHelpers.GetBlockViewByType(db, appUserDetails.AppUserId, LevelEnum.User), UserBranchBlockListView = BlockViewHelpers.GetBlockViewByType(db, appUserDetails.AppUserId, LevelEnum.Branch), UserCompanyBlockListView = BlockViewHelpers.GetBlockViewByType(db, appUserDetails.AppUserId, LevelEnum.Company) }; return(view); }