Пример #1
0
        public object Add()
        {
            if (!this.isValid || tagAlreadyExists())
            {
                return(false);
            }
            if (this.isCommunityHeadTag)
            {
                AdminAdder.AddAdmin(personFromDb.MisparIshi,
                                    false, false /* forceNewAdminLevel */);
            }
            if (this.isAdminChange)
            {
                AdminChangeWriter.WriteAdminChange(
                    String.Format(
                        "Added tag {0} for {1}",
                        TagToPrimeDictionary.PRIME_TO_TAG[tagPrime].Tag,
                        personFromDb.MisparIshi));
            }
            long newTagValue = this.personFromDb.Tags * tagPrime;

            if ((newTagValue > long.MaxValue || newTagValue < this.personFromDb.Tags) && (newTagValue % tagPrime != 0))
            {
                // Here we check if Tags * tagPrime went over the long.MaxValue.
                // Note - The value loops around to negative and continutes rising.
                // So, newTagValue will probably never actually be over MaxValue, so we check if the tag exists
                // in the new tag variable. A complete fix will require changing the way we store tags.
                return(false);
            }
            this.personFromDb.Tags = newTagValue;
            this.dataContext.SubmitChanges();
            return(TagToPrimeDictionary.PRIME_TO_TAG[tagPrime].ToJson());
        }
Пример #2
0
 public bool Delete()
 {
     if (!this.isValid || !tagAlreadyExists())
     {
         return(false);
     }
     if (this.isCommunityHeadTag)
     {
         AdminAdder.DeleteAdmin(personFromDb.MisparIshi);
     }
     if (this.isAdminChange)
     {
         AdminChangeWriter.WriteAdminChange(
             String.Format(
                 "Deleted tag {0} for {1}",
                 TagToPrimeDictionary.PRIME_TO_TAG[tagPrime].Tag,
                 personFromDb.MisparIshi));
     }
     this.personFromDb.Tags /= tagPrime;
     this.dataContext.SubmitChanges();
     return(true);
 }
Пример #3
0
        // POST api/values
        public void Post([FromBody] Request request)
        {
            switch (request.Type)
            {
            case PersonalFieldAdder.WHAT_I_DO:
            case PersonalFieldAdder.ADD_MOBILE:
            case PersonalFieldAdder.ADD_WORK_NUMBER:
            case PersonalFieldAdder.ADD_OTHER_NUMBER:
            case PersonalFieldAdder.SEX:
                PersonalFieldAdder.AddPersonalField(
                    request.MisparIshi, request.Data, request.Type);
                return;

            case "log":
                Logger.Log(request.Logs);
                return;

            case "deletetag":
                TagAdder.DeleteTagForPerson(request.MisparIshi, request.Data);
                return;

            case "reportoddity":     // It's an oddity. We don't write bugs.
                BugReporter.ReportBug(request.Data);
                return;

            case "addadmin":
                AdminAdder.AddAdmin(request.MisparIshi, request.IsSuperAdmin);
                return;

            case "deleteadmin":
                AdminAdder.DeleteAdmin(request.MisparIshi);
                return;

            case "admindeletetag":
                AdminTagDeleter.DeleteTag(request.Data);
                return;
            }
        }