예제 #1
0
        public string Delete(string token)
        {
            token = TokenManager.readToken(HttpContext.Current.Request);
            string message = "";
            var    strP    = TokenManager.GetPrincipal(token);

            if (strP != "0") //invalid authorization
            {
                return(TokenManager.GenerateToken(strP));
            }
            else
            {
                int                 sectionId = 0;
                int                 userId    = 0;
                Boolean             final     = false;
                IEnumerable <Claim> claims    = TokenManager.getTokenClaims(token);
                foreach (Claim c in claims)
                {
                    if (c.Type == "itemId")
                    {
                        sectionId = int.Parse(c.Value);
                    }
                    else if (c.Type == "userId")
                    {
                        userId = int.Parse(c.Value);
                    }
                    else if (c.Type == "final")
                    {
                        final = bool.Parse(c.Value);
                    }
                }
                if (final)
                {
                    try
                    {
                        using (incposdbEntities entity = new incposdbEntities())
                        {
                            sections sectionDelete = entity.sections.Find(sectionId);
                            entity.sections.Remove(sectionDelete);
                            message = entity.SaveChanges().ToString();
                            return(TokenManager.GenerateToken(message));
                        }
                    }
                    catch
                    {
                        message = "0";
                        return(TokenManager.GenerateToken(message));
                    }
                }
                else
                {
                    try
                    {
                        using (incposdbEntities entity = new incposdbEntities())
                        {
                            sections sectionDelete = entity.sections.Find(sectionId);

                            sectionDelete.isActive     = 0;
                            sectionDelete.updateUserId = userId;
                            sectionDelete.updateDate   = DateTime.Now;
                            message = entity.SaveChanges().ToString();
                            return(TokenManager.GenerateToken(message));
                        }
                    }
                    catch
                    {
                        message = "0";
                        return(TokenManager.GenerateToken(message));
                    }
                }
            }
        }
예제 #2
0
    void OnGUI()
    {
        //Debug.Log("id: " + GUIUtility.keyboardControl);
        if  (Event.current.keyCode == KeyCode.Return) { GUIUtility.keyboardControl = 0; Event.current.Use(); }//lose keyboard focus
        //		Current.test = EditorGUILayout.IntField (Current.test, GUILayout.Width (50));
        GUILayout.BeginVertical (); //main
        scrollPos = GUILayout.BeginScrollView(scrollPos);
        GUILayout.BeginHorizontal ();
        if (GUILayout.Button("Core Settings")) current_section = sections.coresettings;
        else if (GUILayout.Button("Card Stats")) current_section = sections.stats;
        //else if (GUILayout.Button("Combat Rules")) current_section = sections.combat;
        else if (GUILayout.Button("Cards Database")) {
            MainMenu.currentsettings = Current;
            cards_db.UpdateCreatures(cards_db.cards);
            current_section = sections.cardsdb;
        }
        GUILayout.EndHorizontal ();

        if  (Event.current.keyCode == KeyCode.F4) Current.core.UseGrid = true;

        switch (current_section)
        {
        case sections.cardsdb :
            cards_db.DrawGUI();
            break;
        case sections.coresettings :
            DrawCoreOptions(Current.core);
            break;
        case sections.combat :
        //			DrawCombat(Current.combat);
            break;
        case sections.stats :
            DrawStats(Current.stats);
            break;
        }

        GUILayout.BeginHorizontal ();
        if (GUILayout.Button("Save Game Settings")) SaveTCGData();
        if (GUILayout.Button("Reload Game Settings")) LoadTCGData();
        GUILayout.EndHorizontal ();

        GUILayout.EndScrollView();
        GUILayout.EndVertical ();
    }
예제 #3
0
        public string Save(string token)
        {
            token = TokenManager.readToken(HttpContext.Current.Request);
            string message = "";
            var    strP    = TokenManager.GetPrincipal(token);

            if (strP != "0") //invalid authorization
            {
                return(TokenManager.GenerateToken(strP));
            }
            else
            {
                string              sectionObject = "";
                sections            newObject     = null;
                IEnumerable <Claim> claims        = TokenManager.getTokenClaims(token);
                foreach (Claim c in claims)
                {
                    if (c.Type == "itemObject")
                    {
                        sectionObject = c.Value.Replace("\\", string.Empty);
                        sectionObject = sectionObject.Trim('"');
                        newObject     = JsonConvert.DeserializeObject <sections>(sectionObject, new IsoDateTimeConverter {
                            DateTimeFormat = "dd/MM/yyyy"
                        });
                        break;
                    }
                }
                if (newObject.updateUserId == 0 || newObject.updateUserId == null)
                {
                    Nullable <int> id = null;
                    newObject.updateUserId = id;
                }
                if (newObject.createUserId == 0 || newObject.createUserId == null)
                {
                    Nullable <int> id = null;
                    newObject.createUserId = id;
                }
                if (newObject.branchId == 0 || newObject.branchId == null)
                {
                    Nullable <int> id = null;
                    newObject.branchId = id;
                }
                try
                {
                    using (incposdbEntities entity = new incposdbEntities())
                    {
                        var sectionEntity = entity.Set <sections>();
                        if (newObject.sectionId == 0)
                        {
                            newObject.createDate   = DateTime.Now;
                            newObject.updateDate   = DateTime.Now;
                            newObject.updateUserId = newObject.createUserId;

                            sectionEntity.Add(newObject);
                            entity.SaveChanges();
                            message = newObject.sectionId.ToString();
                        }
                        else
                        {
                            var tmpSection = entity.sections.Where(p => p.sectionId == newObject.sectionId).FirstOrDefault();
                            tmpSection.name         = newObject.name;
                            tmpSection.branchId     = newObject.branchId;
                            tmpSection.isActive     = newObject.isActive;
                            tmpSection.isFreeZone   = newObject.isFreeZone;
                            tmpSection.note         = newObject.note;
                            tmpSection.updateDate   = DateTime.Now;
                            tmpSection.updateUserId = newObject.updateUserId;
                            entity.SaveChanges();
                            message = tmpSection.sectionId.ToString();
                        }
                    }
                }
                catch
                {
                    message = "-1";
                }
            }
            return(TokenManager.GenerateToken(message));
        }