Beispiel #1
0
        public void UpdateLocationCases(LocationObject lo, AreaInfo ai, CaseInfo ci)
        {
            var collection = db.GetCollection <AreaInfo>("Areas");

            Console.WriteLine(lo.locName + "SHITFUCK");

            collection.FindOneAndUpdate(c => c.areaName == ai.areaName && c.locationsList.Any(s => s.locName == lo.locName),
                                        Builders <AreaInfo> .Update.Push(c => c.locationsList[-1].casesList, ci));
        }
Beispiel #2
0
        public void InsertRecord <T>(string table, T record, string id, string caseID)
        {
            var collection = db.GetCollection <T>(table);


            Type typeParameterType = typeof(T);

            if (typeParameterType.Name == "SerialInfo")
            {
                var serialCollection = db.GetCollection <SerialInfo>("Serial");

                collection.InsertOne(record);

                serialCollection.FindOneAndUpdate(c => c.serial == id,
                                                  Builders <SerialInfo> .Update.Set(c => c.caseID, caseID));
            }
            else if (typeParameterType.Name == "CaseInfo")
            {
                if (!RecordExists <T>(table, id, "caseID"))
                {
                    var caseCollection = db.GetCollection <CaseInfo>("Cases");

                    collection.InsertOne(record);
                }
                else
                {
                    CaseInfo a = (CaseInfo)(object)record;
                    var      caseCollection = db.GetCollection <CaseInfo>("Cases");
                    caseCollection.FindOneAndUpdate(c => c.caseID == id,
                                                    Builders <CaseInfo> .Update.Set(c => c.curLoc, a.curLoc));
                    caseCollection.FindOneAndUpdate(c => c.caseID == id,
                                                    Builders <CaseInfo> .Update.Set(c => c.ageInfo, a.ageInfo));
                }
            }
            else if (typeParameterType.Name == "AreaInfo")
            {
                if (!RecordExists <T>(table, id, "areaName"))
                {
                    var caseCollection = db.GetCollection <AreaInfo>("Areas");

                    collection.InsertOne(record);
                }
            }
            else if (typeParameterType.Name == "LoginModel")
            {
                if (!RecordExists <T>(table, id, "UserName"))
                {
                    var caseCollection = db.GetCollection <LoginModel>("Users");

                    collection.InsertOne(record);
                }
            }
        }
Beispiel #3
0
        public void UpdateCaseSerials(string serial)
        {
            if (RecordExists <SerialInfo>("Serial", serial, "serial"))
            {
                SerialInfo si = LoadRecords <SerialInfo>("Serial", "serial", serial)[0];

                if (RecordExists <CaseInfo>("Cases", si.caseID, "caseID"))
                {
                    var collection = db.GetCollection <CaseInfo>("Cases");

                    CaseInfo ci = LoadRecords <CaseInfo>("Cases", "caseID", si.caseID)[0];

                    if (!ci.serialList.Contains(si))
                    {
                        collection.FindOneAndUpdate(c => c.caseID == ci.caseID,
                                                    Builders <CaseInfo> .Update.Push(c => c.serialList, si));
                    }
                }
            }
        }