public ExtensionService(AccountToService serviceCopy) { this.Id = serviceCopy.PKId; this.Name = serviceCopy.Name; this.Amount = serviceCopy.Amount1; this.Status = serviceCopy.Status.ToString(); this.StatusLastChangedDate = serviceCopy.StatusDate; this.AuthorizationLevel = serviceCopy.AuthorizationLevel.ToString(); this.StartDate = serviceCopy.StartDate; this.EndDate = serviceCopy.EndDate; this.LastChangedDate = serviceCopy.LastChangedDate; this.IsOwner = serviceCopy.IsOwner; this.AccountId = serviceCopy.AccountId; this.ServiceId = serviceCopy.ServiceId; //base table (service being subscribed to or owned) this.Label = serviceCopy.Service.ServiceNum; this.ServiceName = serviceCopy.Service.ServiceName; this.Description = serviceCopy.Service.ServiceDesc; this.Price = serviceCopy.Service.ServicePrice1; this.Unit = serviceCopy.Service.ServiceUnit1; this.ServiceGroupId = serviceCopy.Service.ServiceClassId; this.NetworkId = serviceCopy.Service.NetworkId; this.OwningClubId = serviceCopy.OwningClubId; this.MiscDocPath = string.Empty; }
public static AccountToService GetService(ExtensionService serviceCopy) { AccountToService newService = new AccountToService(); newService.PKId = serviceCopy.Id; newService.Name = serviceCopy.Name; newService.Amount1 = serviceCopy.Amount; newService.Status = Data.AppHelpers.Agreement.SERVICE_STATUS_TYPES.current.ToString(); newService.StatusDate = serviceCopy.StatusLastChangedDate; newService.AuthorizationLevel = (int)AccountHelper.AUTHORIZATION_LEVELS.none; newService.StartDate = serviceCopy.StartDate; newService.EndDate = serviceCopy.EndDate; newService.LastChangedDate = serviceCopy.LastChangedDate; newService.IsOwner = serviceCopy.IsOwner; newService.AccountId = serviceCopy.AccountId; newService.ServiceId = serviceCopy.ServiceId; //base table (service being subscribed to or owned) newService.Service.ServiceNum = serviceCopy.Label; newService.Service.ServiceName = serviceCopy.ServiceName; newService.Service.ServiceDesc = serviceCopy.Description; newService.Service.ServicePrice1 = serviceCopy.Price; newService.Service.ServiceUnit1 = serviceCopy.Unit; newService.Service.ServiceClassId = serviceCopy.ServiceGroupId; newService.Service.NetworkId = serviceCopy.NetworkId; newService.OwningClubId = serviceCopy.OwningClubId; //newService.Service.MiscDocPath = string.Empty; return(newService); }
public async Task <List <AccountToService> > GetServiceByServiceIdAsync( ContentURI uri, int serviceId, bool isOwner) { List <AccountToService> colClubService = new List <AccountToService>(); if (serviceId == 0) { //set default objects AccountToService atos = new AccountToService(true); colClubService.Add(atos); return(colClubService); } int iIsOwner = (isOwner) ? 1 : 0; Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] colPrams = { sqlIO.MakeInParam("@ServiceId", SqlDbType.Int, 4, serviceId), sqlIO.MakeInParam("@IsOwner", SqlDbType.Bit, 1, iIsOwner) }; //this sp must also run a subquery that sets the owning club id SqlDataReader dataReader = await sqlIO.RunProcAsync( "0GetServicesByServiceId", colPrams); colClubService = FillClubServiceList(dataReader); sqlIO.Dispose(); return(colClubService); }
public List <AccountToService> FillClubServiceList(SqlDataReader services) { List <AccountToService> colService = new List <AccountToService>(); if (services != null) { using (services) { //build a related service list to return to the client while (services.Read()) { AccountToService newService = new AccountToService(); newService.Service = new Service(); newService.PKId = services.GetInt32(0); newService.Name = services.GetString(1); newService.Amount1 = services.GetInt32(2); newService.Status = services.GetString(3); newService.LastChangedDate = services.GetDateTime(4); newService.AuthorizationLevel = services.GetInt16(5); newService.StartDate = services.GetDateTime(6); newService.EndDate = services.GetDateTime(7); newService.LastChangedDate = services.GetDateTime(8); newService.IsOwner = services.GetBoolean(9); newService.AccountId = services.GetInt32(10); newService.ServiceId = services.GetInt32(11); //base table (service being subscribed to or owned) newService.Service = new Service(); newService.Service.ServiceNum = services.GetString(12); newService.Service.ServiceName = services.GetString(13); newService.Service.ServiceDesc = services.GetString(14); newService.Service.ServicePrice1 = services.GetDecimal(15); newService.Service.ServiceUnit1 = services.GetString(16); newService.Service.ServiceClassId = services.GetInt32(17); newService.Service.NetworkId = services.GetInt32(18); newService.OwningClubId = services.GetInt32(19); newService.Service.ServiceCurrency1 = services.GetString(20); newService.Account = new Account(); newService.Account.PKId = services.GetInt32(21); newService.Account.AccountName = services.GetString(22); newService.Account.AccountDesc = services.GetString(23); newService.Account.AccountLongDesc = services.GetString(24); newService.Account.AccountEmail = services.GetString(25); newService.Account.AccountURI = services.GetString(26); newService.Account.AccountClassId = services.GetInt32(27); newService.Account.GeoRegionId = services.GetInt32(28); //not in db newService.Account.ClubDocFullPath = string.Empty; newService.Account.PrivateAuthorizationLevel = AccountHelper.AUTHORIZATION_LEVELS.none; newService.Account.NetCost = 0; newService.Account.TotalCost = 0; newService.Account.URIFull = string.Empty; colService.Add(newService); } } } return(colService); }
//deprecated in 2.0.0 in favor of uniform EF form edits //public async Task<bool> UpdateDefaultClubAsync(ContentURI uri, string editAttName, // int id) //{ // bool bIsUpdated = false; // int iAuthorizationLevel = (int)AccountHelper.AUTHORIZATION_LEVELS.viewonly; // int iAccountId = 0; // try // { // //update the database and db model // IList<AccountToMember> members = await _dataContext.AccountToMember // .Where(cm => cm.MemberId == uri.URIMember.MemberId) // .ToListAsync(); // //execute the query, and make edit changes // bool bIsDefaultClub = false; // if (members != null) // { // foreach (AccountToMember cm in members) // { // bIsDefaultClub = false; // AccountToMember existingAM = await _dataContext.AccountToMember.SingleOrDefaultAsync(x => x.PKId == cm.PKId); // if (existingAM != null) // { // //tell the tracker to change the state is unchanged // _dataContext.Entry(existingAM).State = EntityState.Unchanged; // if (cm.AccountId == id) // { // if (editAttName == AppHelpers.Members.ISDEFAULTCLUB) // { // bIsDefaultClub = true; // existingAM.IsDefaultClub = bIsDefaultClub; // //don't set these to null or changes uri // //existingAM.ClubDefault = null; // //existingAM.Member = null; // } // } // else // { // existingAM.IsDefaultClub = bIsDefaultClub; // existingAM.ClubDefault = null; // existingAM.Member = null; // } // _dataContext.Entry(existingAM).State = EntityState.Modified; // } // } // await _dataContext.SaveChangesAsync(); // bIsUpdated = true; // UpdateListsAsync(uri, iAccountId, iAuthorizationLevel, id); // } // } // catch (Exception e) // { // uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg( // e.InnerException.ToString(), "ERROR_INTRO"); // } // return bIsUpdated; //} private void UpdateListsAsync(ContentURI uri, int accountId, int authorizationLevel, int id) { if (uri.URIDataManager.AppType == Helpers.GeneralHelpers.APPLICATION_TYPES.agreements) { //update the DevTreks model if (uri.URIService != null) { if (uri.URIService.Service != null) { if (uri.URIService.Service.SubscribedClubs != null) { if (uri.URIService.Service.SubscribedClubs.Count > 0) { AccountToService oSubscribedClub = uri.URIService.Service.SubscribedClubs.FirstOrDefault( c => c.PKId == id); if (oSubscribedClub != null) { oSubscribedClub.AuthorizationLevel = (short)authorizationLevel; } } } } } } else if (uri.URIDataManager.AppType == Helpers.GeneralHelpers.APPLICATION_TYPES.members) { if (uri.URIMember.Member != null) { if (uri.URIMember.Member.AccountToMember != null) { foreach (AccountToMember memberClub in uri.URIMember.Member.AccountToMember) { if (memberClub.AccountId == id) { memberClub.IsDefaultClub = true; } else { memberClub.IsDefaultClub = false; } } } } } }
private bool UpdateSubscribedServiceMemberCount(ContentURI agreementURI, AccountToService accountService, bool isOwner, int currentClubMemberCount, int memberCount) { bool bHasUpdated = false; if (!isOwner) { AppHelpers.Agreement aggreement = new Agreement(); //bHasUpdated = aggreement.UpdateSubscribedMemberCount(agreementURI, currentClubMemberCount, // accountService.AccountId, accountService.PKId, memberCount); } return(bHasUpdated); }
public async Task <bool> UpdateSubscribedMemberCountAsync(ContentURI uri, int currentClubMemberCount, int accountId, int joinServiceId, int memberCount) { //service agreement revenues are derived from subscribing clubs member count //(fees are charged per club member) bool bHasUpdated = false; if (uri.URIMember.ClubInUse != null && uri.URIMember.ClubDefault != null && joinServiceId != 0 && accountId != 0) { if (uri.URIMember.ClubInUse.PrivateAuthorizationLevel == AccountHelper.AUTHORIZATION_LEVELS.fulledits && uri.URIMember.ClubDefault.PKId == accountId) { if (currentClubMemberCount != memberCount) { //update the database and db model try { //update the database and db model AccountToService existingAC = await _dataContext.AccountToService.SingleOrDefaultAsync(x => x.PKId == joinServiceId); if (existingAC != null) { //tell the tracker to change the state is unchanged _dataContext.Entry(existingAC).State = EntityState.Unchanged; //execute the query, and make edit changes existingAC.Amount1 = currentClubMemberCount; existingAC.LastChangedDate = Helpers.GeneralHelpers.GetDateShortNow(); _dataContext.Entry(existingAC).State = EntityState.Modified; //state is now modified and can be updated await _dataContext.SaveChangesAsync(); bHasUpdated = true; } } catch (Exception e) { uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg( e.InnerException.ToString(), "MEMBERREPOSIT_UPcDateAGREEMENTAMOUNT"); } } } } return(bHasUpdated); }
private void SetHostFee(ContentURI uri, AccountToService accountservice, double totalServiceCost) { double dbHostFee = (double)accountservice.HostServiceFee; string sHostRate = uri.URIDataManager.HostFeeRate; if (string.IsNullOrEmpty(sHostRate)) { sHostRate = "0"; } double dbHostRate = Helpers.GeneralHelpers.ConvertStringToDouble(sHostRate); accountservice.HostServiceRate = dbHostRate; dbHostFee = (totalServiceCost * accountservice.HostServiceRate); accountservice.HostServiceFee = Math.Round((decimal)dbHostFee, 2); }
public AccountToService FillServiceObject(SqlDataReader service) { //this is a one-record reader int i = 0; //avoid null refs with object props AccountToService newService = new AccountToService(true); if (service != null) { using (service) { while (service.Read()) { if (i == 0) { newService.PKId = service.GetInt32(0); newService.Name = service.GetString(1); newService.Amount1 = service.GetInt32(2); newService.Status = service.GetString(3); newService.StatusDate = service.GetDateTime(4); newService.AuthorizationLevel = service.GetInt16(5); newService.StartDate = service.GetDateTime(6); newService.EndDate = service.GetDateTime(7); newService.LastChangedDate = service.GetDateTime(8); newService.IsOwner = service.GetBoolean(9); newService.AccountId = service.GetInt32(10); newService.ServiceId = service.GetInt32(11); //base table (service being subscribed to or owned) newService.Service = new Service(); newService.Service.PKId = newService.ServiceId; newService.Service.ServiceNum = service.GetString(12); newService.Service.ServiceName = service.GetString(13); newService.Service.ServiceDesc = service.GetString(14); newService.Service.ServicePrice1 = service.GetDecimal(15); newService.Service.ServiceUnit1 = service.GetString(16); newService.Service.ServiceClassId = service.GetInt32(17); //must switch uripatterns from now on to this networkid (on service layer) newService.Service.NetworkId = service.GetInt32(18); newService.OwningClubId = service.GetInt32(19); } i++; } } } return(newService); }
private decimal GetMonthlyEquivalentTotals(AccountToService accountService) { decimal dTotalCost = accountService.Service.ServicePrice1 * accountService.Amount1; //convert costs to monthy basis for uniformity if (accountService.Service.ServiceUnit1 == Agreement.SERVICE_UNIT_TYPES.day.ToString()) { dTotalCost = dTotalCost * 30; } else if (accountService.Service.ServiceUnit1 == Agreement.SERVICE_UNIT_TYPES.month.ToString()) { //good total on hand } else if (accountService.Service.ServiceUnit1 == Agreement.SERVICE_UNIT_TYPES.year.ToString()) { dTotalCost = dTotalCost / 12; } return(Math.Round(dTotalCost, 2)); }
public async Task <List <AccountToService> > GetRelatedServiceAsync( SearchManager searcher) { List <AccountToService> colService = new List <AccountToService>(); AccountToService serviceSelected = new AccountToService(true); if (searcher.NetworkType != DevTreks.Data.AppHelpers.Networks.NETWORK_FILTER_TYPES.allnetworks && searcher.NetworkSelected.PKId != 0) { colService = await _repository.GetRelatedServiceAsync(searcher); } serviceSelected = colService.FirstOrDefault( s => s.PKId == searcher.SearchResult.URIService.PKId); if (serviceSelected != null) { serviceSelected.IsSelected = true; } else { if (searcher.SearchResult.URIService != null) { serviceSelected = searcher.SearchResult.URIService; } else { if (colService.Count > 0) { serviceSelected = colService[0]; } } if (serviceSelected != null) { serviceSelected.IsSelected = true; } } if (serviceSelected == null) { serviceSelected = new AccountToService(true); } searcher.ServiceSelected = serviceSelected; return(colService); }
private async Task <bool> UpdateAuthorizationLevelAsync(ContentURI uri, string editAttName, string editAttValue, int id) { bool bIsUpdated = false; int iAuthorizationLevel = (int)AccountHelper.AUTHORIZATION_LEVELS.viewonly; int iAccountId = 0; //submit the changes to the database. try { //update the database and db model AccountToService existingAC = await _dataContext.AccountToService.SingleOrDefaultAsync(x => x.PKId == id); if (existingAC != null) { //tell the tracker to change the state is unchanged _dataContext.Entry(existingAC).State = EntityState.Unchanged; //execute the query, and make edit changes if (editAttName.Contains(AppHelpers.Members.AUTHORIZATION_LEVEL)) { iAuthorizationLevel = Helpers.GeneralHelpers.ConvertStringToInt(editAttValue); existingAC.AuthorizationLevel = (short)iAuthorizationLevel; iAccountId = existingAC.AccountId; existingAC.Account = null; existingAC.Service = null; _dataContext.Entry(existingAC).State = EntityState.Modified; //state is now modified and can be updated await _dataContext.SaveChangesAsync(); } bIsUpdated = true; UpdateListsAsync(uri, iAccountId, iAuthorizationLevel, id); } } catch (Exception e) { uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg( e.InnerException.ToString(), "ERROR_INTRO"); } return(bIsUpdated); }
public async Task <List <AccountToMember> > GetClubByServiceAndMemberAsync( ContentURI uri, int serviceId, int memberId) { List <AccountToMember> clubs = new List <AccountToMember>(); if (memberId == 0 || serviceId == 0) { AccountToMember club = new AccountToMember(true); //return blank member and service if not a real member or a real service club.ClubDefault = new Account(true); club.Member = new Member(true); clubs.Add(club); return(clubs); } Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri); SqlParameter[] colPrams = { sqlIO.MakeInParam("@MemberId", SqlDbType.Int, 4, memberId), sqlIO.MakeInParam("@ServiceId", SqlDbType.Int, 4, serviceId) }; SqlDataReader dataReader = await sqlIO.RunProcAsync( "0GetClubByServiceAndMemberIds", colPrams); if (dataReader != null) { //discrepency in field order between cloud and local db Helpers.FileStorageIO.PLATFORM_TYPES ePlatform = uri.URIDataManager.PlatformType; using (dataReader) { while (await dataReader.ReadAsync()) { AccountToMember club = new AccountToMember(); club.ClubInUse = new Account(); club.Member = new Member(); //order is Account, Member, AccountToMember //set club in use //Account.PKId club.ClubInUse.PKId = dataReader.GetInt32(0); //Account.AccountName club.ClubInUse.AccountName = dataReader.GetString(1); //Account.AccountDesc club.ClubInUse.AccountDesc = dataReader.GetString(2); //Account.AccountLongDesc club.ClubInUse.AccountLongDesc = dataReader.GetString(3); //Account.AccountEmail club.ClubInUse.AccountEmail = dataReader.GetString(4); //Account.AccountURI club.ClubInUse.AccountURI = dataReader.GetString(5); //Account.AccountClassId club.ClubInUse.AccountClassId = dataReader.GetInt32(6); //Account.GeoRegionId club.ClubInUse.GeoRegionId = dataReader.GetInt32(7); //not in db club.ClubInUse.ClubDocFullPath = string.Empty; club.ClubInUse.PrivateAuthorizationLevel = AccountHelper.AUTHORIZATION_LEVELS.none; club.ClubInUse.NetCost = 0; club.ClubInUse.TotalCost = 0; club.ClubInUse.URIFull = string.Empty; //set member club.Member.PKId = dataReader.GetInt32(8); if (ePlatform == Helpers.FileStorageIO.PLATFORM_TYPES.azure) { //Member.MemberEmail club.Member.MemberEmail = dataReader.GetString(9); //Member.UserName club.Member.UserName = dataReader.GetString(10); } else { //Member.UserName club.Member.UserName = dataReader.GetString(9); //Member.MemberEmail club.Member.MemberEmail = dataReader.GetString(10); } club.Member.MemberJoinedDate = dataReader.GetDateTime(11); club.Member.MemberLastChangedDate = dataReader.GetDateTime(12); club.Member.MemberFirstName = dataReader.GetString(13); club.Member.MemberLastName = dataReader.GetString(14); club.Member.MemberDesc = dataReader.GetString(15); club.Member.MemberOrganization = dataReader.GetString(16); club.Member.MemberAddress1 = dataReader.GetString(17); club.Member.MemberAddress2 = dataReader.GetString(18); club.Member.MemberCity = dataReader.GetString(19); club.Member.MemberState = dataReader.GetString(20); club.Member.MemberCountry = dataReader.GetString(21); club.Member.MemberZip = dataReader.GetString(22); club.Member.MemberPhone = dataReader.GetString(23); club.Member.MemberPhone2 = dataReader.GetString(24); club.Member.MemberFax = dataReader.GetString(25); club.Member.MemberUrl = dataReader.GetString(26); club.Member.MemberClassId = dataReader.GetInt32(27); club.Member.GeoRegionId = dataReader.GetInt32(28); club.Member.AspNetUserId = dataReader.GetString(29); //set accounttomember //AccountToMember.PKId club.PKId = dataReader.GetInt32(30); club.IsDefaultClub = dataReader.GetBoolean(31); club.MemberRole = dataReader.GetString(32); club.AccountId = dataReader.GetInt32(33); club.MemberId = dataReader.GetInt32(34); //not part of db club.AuthorizationLevel = (int)AccountHelper.AUTHORIZATION_LEVELS.none; club.MemberDocFullPath = string.Empty; club.URIFull = string.Empty; //the authorization level comes from this join AccountToService service = new AccountToService(); service.PKId = dataReader.GetInt32(35); service.Name = dataReader.GetString(36); service.Amount1 = dataReader.GetInt32(37); service.Status = dataReader.GetString(38); service.LastChangedDate = dataReader.GetDateTime(39); service.AuthorizationLevel = dataReader.GetInt16(40); service.StartDate = dataReader.GetDateTime(41); service.EndDate = dataReader.GetDateTime(42); service.LastChangedDate = dataReader.GetDateTime(43); service.IsOwner = dataReader.GetBoolean(44); service.AccountId = dataReader.GetInt32(45); service.ServiceId = dataReader.GetInt32(46); //this is used to set ClubInUseAuthorizationLevel club.ClubInUse.PrivateAuthorizationLevel = AccountHelper.GetAuthorizationLevel(service.AuthorizationLevel); clubs.Add(club); } } } else { //set default objects AccountToMember club = new AccountToMember(true); //return blank member and service if not a real member or a real service club.ClubInUse = new Account(true); club.Member = new Member(true); clubs.Add(club); } sqlIO.Dispose(); return(clubs); }
//note that get selections is only join table insertions private async Task <bool> AddService(List <ContentURI> addedURIs, List <AccountToService> addedAToSs, List <Service> addedSs) { bool bHasSet = true; string sParentNodeName = string.Empty; int iParentId = 0; foreach (ContentURI addedURI in addedURIs) { Helpers.GeneralHelpers.GetParentIdAndNodeName(addedURI, out iParentId, out sParentNodeName); if (!string.IsNullOrEmpty(addedURI.ErrorMessage)) { _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg( string.Empty, "INSERT_NOPARENT"); return(false); } if (addedURI.URINodeName == Agreement.AGREEMENT_TYPES.service.ToString()) { //addedURI.URIId == ServiceClassId == SubAppType; must be below 1000 to add a base service int iMaxSubApp = (int)Helpers.GeneralHelpers.SUBAPPLICATION_TYPES.resources; if (addedURI.URIId <= iMaxSubApp && _dtoContentURI.URINodeName == Agreement.AGREEMENT_TYPES.serviceaccount.ToString()) { //base table gets inserted first //2.0.0 refactor: EF no longer allows fks = 0; so changed to new NetworkId = 1 //new table row inserted for this purpose in table Network (see Source Code documentation) int iNetworkId = 1; //int iNetworkId = 0; //if (_dtoContentURI.URINetwork != null) //{ // iNetworkId = _dtoContentURI.URINetwork.PKId; //} var newService = new Service { ServiceNum = Helpers.GeneralHelpers.NONE, ServiceName = addedURI.URIName, ServiceDesc = Helpers.GeneralHelpers.NONE, ServicePrice1 = 0, ServiceUnit1 = Agreement.SERVICE_UNIT_TYPES.month.ToString(), ServiceCurrency1 = Agreement.SERVICE_CURRENCY_TYPES.usdollar.ToString(), //chosen after insertion NetworkId = iNetworkId, Network = null, //stored as the uriid ServiceClassId = addedURI.URIId, ServiceClass = null, AccountToService = null, BudgetSystem = null, ComponentClass = null, CostSystem = null, DevPackClass = null, InputClass = null, LinkedViewClass = null, OperationClass = null, OutcomeClass = null, OutputClass = null, ResourceClass = null }; _dataContext.Service.Add(newService); _dataContext.Entry(newService).State = EntityState.Added; addedSs.Add(newService); } else { //addedURI.URIId == joinid; need base serviceid var accounttoservice = await _dataContext.AccountToService.SingleOrDefaultAsync(x => x.PKId == addedURI.URIId); if (accounttoservice != null) { var newAccountToService = new AccountToService { Name = accounttoservice.Name, Amount1 = 1, Status = Agreement.SERVICE_STATUS_TYPES.current.ToString(), StatusDate = Helpers.GeneralHelpers.GetDateShortNow(), AuthorizationLevel = (short)Agreement.PUBLIC_AUTHORIZATION_TYPES.public_not_authorized, StartDate = Helpers.GeneralHelpers.GetDateShortNow(), EndDate = Helpers.GeneralHelpers.GetDateShortNow(), LastChangedDate = Helpers.GeneralHelpers.GetDateShortNow(), IsOwner = false, AccountId = _dtoContentURI.URIId, Account = null, ServiceId = accounttoservice.ServiceId, Service = null, AccountToIncentive = null, AccountToPayment = null }; _dataContext.AccountToService.Add(newAccountToService); _dataContext.Entry(newAccountToService).State = EntityState.Added; addedAToSs.Add(newAccountToService); } } } else if (addedURI.URINodeName == Agreement.AGREEMENT_TYPES.incentive.ToString()) { //don't allow incentive insertions until they are needed } } return(bHasSet); }
public async Task <bool> AddService(EditHelper.ArgumentsEdits argumentsEdits) { bool bIsAdded = false; //store updated service ids in lists List <Service> addedSs = new List <Service>(); List <AccountToService> addedAToSs = new List <AccountToService>(); bool bHasSet = await AddService(argumentsEdits.SelectionsToAdd, addedAToSs, addedSs); if (addedAToSs.Count > 0 || addedSs.Count > 0) { try { //save selected subscription (atoss) and base services(addess) int iNotUsed = await _dataContext.SaveChangesAsync(); bIsAdded = true; if (addedSs.Count > 0) { bIsAdded = false; foreach (var service in addedSs) { //have a good base table insertion, now can insert join //only time isowner should be ever set bool bIsOwner = true; var newAccountToService = new AccountToService { Name = service.ServiceName, Amount1 = 1, Status = Agreement.SERVICE_STATUS_TYPES.current.ToString(), StatusDate = Helpers.GeneralHelpers.GetDateShortNow(), AuthorizationLevel = (short)Agreement.PUBLIC_AUTHORIZATION_TYPES.public_not_authorized, StartDate = Helpers.GeneralHelpers.GetDateShortNow(), EndDate = Helpers.GeneralHelpers.GetDateShortNow(), LastChangedDate = Helpers.GeneralHelpers.GetDateShortNow(), IsOwner = bIsOwner, AccountId = _dtoContentURI.URIId, Account = null, ServiceId = service.PKId, Service = null, AccountToIncentive = null, AccountToPayment = null }; _dataContext.AccountToService.Add(newAccountToService); _dataContext.Entry(newAccountToService).State = EntityState.Added; iNotUsed = await _dataContext.SaveChangesAsync(); bIsAdded = true; } } //only the edit panel needs an updated collection of services if (_dtoContentURI.URIDataManager.ServerActionType == Helpers.GeneralHelpers.SERVER_ACTION_TYPES.edit) { bHasSet = await SetURIService(_dtoContentURI, false); } } catch (Exception e) { _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg( e.ToString(), "ERROR_INTRO"); } if (_dtoContentURI.ErrorMessage.Length > 0) { bHasSet = await SetURIService(_dtoContentURI, false); } } return(bIsAdded); }