1
0
mirror of https://github.com/chyzy/RSystem-MVC synced 2024-11-26 08:10:28 +01:00
RSystem-MVC-Fork/RSystem/Managers/JSONParserManager.cs

38 lines
1.0 KiB
C#
Raw Normal View History

2018-04-17 11:20:49 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using Microsoft.Ajax.Utilities;
using Newtonsoft.Json;
using RSystem.Models;
namespace RSystem.Managers
{
public class JsonIntermediateMutipiler
{
public int? matura { get; set; }
public float? val { get; set; }
}
public class JSONParserManager
{
public static IEnumerable<PointsMultipiler> JsonToPointsMultipilers(string json,int id)
{
var intermediateModel = JsonConvert.DeserializeObject<IEnumerable<JsonIntermediateMutipiler>>(json);
foreach (var mutipiler in intermediateModel)
{
if(mutipiler.matura!=null && mutipiler.val!=null)
yield return new PointsMultipiler()
{
Multipiler = (float)mutipiler.val,
MaturaSubjectId = (int)mutipiler.matura,
SpecializationId = id
};
}
}
}
}