Ejemplo n.º 1
0
 public async Task SaveFigureAsync(Guid id, double area)
 {
     using (var db = new FigureContext())
     {
         db.Add(new db.Figure()
         {
             Id   = id,
             Area = area
         });
         await db.SaveChangesAsync();
     }
 }
Ejemplo n.º 2
0
        public async Task <Double> GetAreaAsync(Guid id)
        {
            using (var db = new FigureContext())
            {
                var figure = await db.Figures.FindAsync(id);

                if (figure == null)
                {
                    throw new BusinessLogicException($"Figure {id} not found");
                }
                return(figure.Area);
            }
        }
Ejemplo n.º 3
0
 public bl.Figure Load(Guid id)
 {
     using (var db = new FigureContext())
     {
         var figure = db.Figures.Find(id);
         if (figure == null)
         {
             return(null);
         }
         return(JsonConvert.DeserializeObject <bl.Figure>(figure.Data, new JsonSerializerSettings {
             TypeNameHandling = TypeNameHandling.All
         }));
     }
 }
Ejemplo n.º 4
0
 public void Save(bl.Figure figure)
 {
     using (var db = new FigureContext())
     {
         db.Add(new db.Figure()
         {
             Id   = figure.Id,
             Data = JsonConvert.SerializeObject(figure, new JsonSerializerSettings {
                 TypeNameHandling = TypeNameHandling.All
             })
         });
         db.SaveChanges();
     }
 }