Exemple #1
0
        public void Modify(ReportData reportData, JToken json)
        {
            reportData.Category = json.Value<string>("category") ?? reportData.Category;

            reportData.IsVisible = json.Value<bool?>("isVisible") ?? reportData.IsVisible;

            var statusString = json["status"] != null ? json.Value<string>("status") : null;
            reportData.Status = statusString != null ? (StatusEnum)Enum.Parse(typeof(StatusEnum), statusString, true) : reportData.Status;

            reportData.Description = json.Value<string>("description") ?? reportData.Description;

            reportData.IsUnconscious = json.Value<bool?>("isUnconscious") ?? reportData.IsUnconscious;

            reportData.StolenObject = json.Value<string>("stolenObject") ?? reportData.StolenObject;
            reportData.DateOfTheft = json.Value<DateTime?>("dateOfTheft") ?? reportData.DateOfTheft;

            reportData.DrugsAction = json.Value<string>("drugsAction") ?? reportData.DrugsAction;

            reportData.FighterCount = json.Value<int?>("fighterCount") ?? reportData.FighterCount;
            reportData.IsWeaponPresent = json.Value<bool?>("isWeaponPresent") ?? reportData.IsWeaponPresent;

            reportData.WeaponType = json.Value<string>("weaponType") ?? reportData.WeaponType;
            reportData.WeaponLocation = json.Value<string>("weaponLocation") ?? reportData.WeaponLocation;

            reportData.Victim = json.Value<string>("victim") ?? reportData.Victim;
            reportData.VictimName = json.Value<string>("victimName") ?? reportData.VictimName;

            if (json["location"] != null)
            {
                reportData.Location = Modify(reportData.Location, json["location"]);
            }
            if (json["contact"] != null)
            {
                reportData.Contact = Modify(reportData.Contact, json["contact"]);
            }
            if (json["perpetrator"] != null)
            {
                reportData.Perpetrator = Modify(reportData.Perpetrator, json["perpetrator"]);
            }
            if (json["vehicle"] != null)
            {
                reportData.Vehicle = Modify(reportData.Vehicle, json["vehicle"]);
            }
        }
Exemple #2
0
 public ReportData Create(JToken json)
 {
     var reportData = new ReportData();
     Modify(reportData, json);
     return reportData;
 }