Beispiel #1
0
        public async Task <bool> DeleteLocals(EditHelper.ArgumentsEdits argumentsEdits)
        {
            bool bIsDeleted = false;
            //store updated resources ids in node name and id dictionary
            Dictionary <string, int> deletedIds = new Dictionary <string, int>();
            bool bHasSet = await DeleteLocals(argumentsEdits.SelectionsToAdd, deletedIds);

            if (deletedIds.Count > 0)
            {
                try
                {
                    int iNotUsed = await _dataContext.SaveChangesAsync();

                    bIsDeleted = true;
                    //update the dtoContentURI collection
                    bHasSet = await SetURILocals(_dtoContentURI, false);
                }
                catch (Exception e)
                {
                    _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                        e.ToString(), "ERROR_INTRO");
                }
                if (_dtoContentURI.ErrorMessage.Length > 0)
                {
                    bHasSet = await SetURILocals(_dtoContentURI, false);
                }
            }
            return(bIsDeleted);
        }
Beispiel #2
0
        public async Task <bool> ChangeAccountPropertyValues(
            EditHelper.ArgumentsEdits argumentsEdits)
        {
            bool bHasSet     = false;
            int  iEmailCount = 0;

            if (argumentsEdits.EditAttName.ToLower().Contains(
                    AppHelpers.Accounts.ACCOUNT_EMAIL.ToLower()))
            {
                IMemberRepositoryEF rep
                            = new SqlRepositories.MemberRepository(argumentsEdits.URIToEdit);
                iEmailCount = await rep.GetEmailCountForClubAsync(
                    argumentsEdits.EditAttValue);

                rep = null;
                if (iEmailCount != 0)
                {
                    _dtoContentURI.ErrorMessage
                        = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                              string.Empty, "EDIT_EMAILINUSE");
                }
                else
                {
                    bHasSet = true;
                }
            }
            return(bHasSet);
        }
Beispiel #3
0
        public async Task <bool> AddLocals(EditHelper.ArgumentsEdits argumentsEdits)
        {
            bool bIsAdded = false;
            //store updated resources ids in lists
            List <AccountToLocal> addedMs = new List <AccountToLocal>();
            bool bHasSet = AddLocals(argumentsEdits.SelectionsToAdd, addedMs);

            if (addedMs.Count > 0)
            {
                try
                {
                    int iNotUsed = await _dataContext.SaveChangesAsync();

                    bIsAdded = true;
                    //only the edit panel needs an updated collection of resources
                    if (_dtoContentURI.URIDataManager.ServerActionType
                        == Helpers.GeneralHelpers.SERVER_ACTION_TYPES.edit)
                    {
                        bHasSet = await SetURILocals(_dtoContentURI, false);
                    }
                }
                catch (Exception e)
                {
                    _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                        e.ToString(), "ERROR_INTRO");
                }
                if (_dtoContentURI.ErrorMessage.Length > 0)
                {
                    bHasSet = await SetURILocals(_dtoContentURI, false);
                }
            }
            return(bIsAdded);
        }
        private async Task <bool> ChangeMemberPropertyValues(EditHelper.ArgumentsEdits argumentsEdits, Dictionary <string, int> updatedIds)
        {
            bool bHasSet = true;

            if (argumentsEdits.EditAttName.ToLower().Contains(
                    Members.MEMBER_USERNAME.ToLower()))
            {
                IMemberRepositoryEF rep
                    = new SqlRepositories.MemberRepository(argumentsEdits.URIToEdit);
                int iUserNameCount = await rep.GetUserNameCountForMemberAsync(
                    argumentsEdits.EditAttValue);

                if (iUserNameCount != 0)
                {
                    _dtoContentURI.ErrorMessage
                        = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                              string.Empty, "EDIT_USERNAMEINUSE");
                }
            }
            else if (argumentsEdits.EditAttName.ToLower().Contains(
                         Members.MEMBER_EMAIL.ToLower()))
            {
                IMemberRepositoryEF rep
                    = new SqlRepositories.MemberRepository(argumentsEdits.URIToEdit);
                int iEmailCount = await rep.GetEmailCountForMemberAsync(
                    argumentsEdits.EditAttValue);

                if (iEmailCount != 0)
                {
                    _dtoContentURI.ErrorMessage
                        = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                              string.Empty, "EDIT_EMAILINUSE");
                }
            }
            else if (argumentsEdits.EditAttName.ToLower().Contains(
                         AppHelpers.Members.MEMBER_ROLE.ToLower()))
            {
                //the club founder (topjoin) can't change role from coordinator
                //fallback so that all clubs have at least one coordinator who
                //can edit the club's model
                bool       bJoinIdsMatch = false;
                EditHelper editHelper    = new EditHelper();
                //don't use uri.urinodename here (can be a parent uri)
                bJoinIdsMatch = await editHelper.JoinIdsAreMatches(_dtoContentURI, argumentsEdits,
                                                                   AppHelpers.Members.MEMBER_TYPES.member.ToString(),
                                                                   _dtoContentURI.URIMember.MemberId.ToString());

                if (bJoinIdsMatch)
                {
                    _dtoContentURI.ErrorMessage
                        = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                              string.Empty, "EDIT_NOFOUNDERCHANGE");
                }
            }
            return(bHasSet);
        }
        public async Task <bool> DeleteMember(EditHelper.ArgumentsEdits argumentsEdits)
        {
            bool bIsDeleted = false;
            bool bHasSet    = false;
            //last member deletion will also try to delete club
            int iAccountId = await NeedsClubDeletion(argumentsEdits.SelectionsToAdd);

            if (string.IsNullOrEmpty(_dtoContentURI.ErrorMessage))
            {
                //store updated resources ids in node name and id dictionary
                Dictionary <string, int> deletedIds = new Dictionary <string, int>();
                bHasSet = await DeleteMember(argumentsEdits.SelectionsToAdd, deletedIds);

                if (deletedIds.Count > 0 && string.IsNullOrEmpty(_dtoContentURI.ErrorMessage))
                {
                    try
                    {
                        int iNotUsed = await _dataContext.SaveChangesAsync();

                        bIsDeleted = true;
                        //update the dtoContentURI collection
                        bHasSet = await SetURIMember(_dtoContentURI, false);
                    }
                    catch (Exception e)
                    {
                        _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                            e.ToString(), "ERROR_INTRO");
                    }
                    if (_dtoContentURI.ErrorMessage.Length > 0)
                    {
                        bHasSet = await SetURIMember(_dtoContentURI, false);
                    }
                }
            }
            else
            {
                bHasSet = await SetURIMember(_dtoContentURI, false);
            }
            if (iAccountId != 0)
            {
                //db cascading deletes won't work here -the members have to deleted first
                //chance of stranded clubs, but that might be a good security recovery feature
                bHasSet = await DeleteLastMemberClub(iAccountId);
            }
            return(bIsDeleted);
        }
Beispiel #6
0
        public async Task <bool> DeleteService(EditHelper.ArgumentsEdits argumentsEdits)
        {
            bool bIsDeleted = false;
            bool bHasSet    = false;

            //stored procedures are used to make cascading deletes easier
            bIsDeleted = await DeleteService(argumentsEdits.SelectionsToAdd);

            if (bIsDeleted)
            {
                //update the dtoContentURI collection
                bHasSet = await SetURIService(_dtoContentURI, false);
            }
            else
            {
                //update the dtoContentURI collection
                bHasSet = await SetURIService(_dtoContentURI, false);

                _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                    string.Empty, "DELETESERVICE_FAIL");
            }
            return(bIsDeleted);
        }
        private async Task <bool> UpdateBaseMemberEntity(EditHelper.ArgumentsEdits edit, Dictionary <string, int> updatedIds)
        {
            bool   bHasSet  = true;
            string sKeyName = string.Empty;
            var    member   = await _dataContext.Member.SingleOrDefaultAsync(x => x.PKId == edit.URIToAdd.URIId);

            if (member != null)
            {
                RuleHelpers.GeneralRules.ValidateXSDInput(edit);
                //update the property to the new value
                string sErroMsg = string.Empty;
                EditModelHelper.UpdateDbEntityProperty(_dataContext.Entry(member), edit.EditAttName,
                                                       edit.EditAttValue, edit.EditDataType, ref sErroMsg);
                _dtoContentURI.ErrorMessage      = sErroMsg;
                _dataContext.Entry(member).State = EntityState.Modified;
                sKeyName = string.Concat(edit.URIToAdd.URINodeName, edit.URIToAdd.URIId);
                if (updatedIds.ContainsKey(sKeyName) == false)
                {
                    updatedIds.Add(sKeyName, edit.URIToAdd.URIId);
                }
            }
            return(bHasSet);
        }
Beispiel #8
0
        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);
        }