joseh254

BidService

Mar 26th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using EpicCars;
  6. using System.IO;
  7. using Newtonsoft.Json;
  8.  
  9. namespace EpicCars
  10. {
  11.     public class BidService
  12.     {
  13.          private string _filePath = @"C:\Users\2015A320\Source\Repos\EpicU_JoseHernandez\EpicCars\EpicCars";
  14.  
  15.             public Bid GetBidders()
  16.             {
  17.                 string fullName = Path.Combine(_filePath, "Bid.json");
  18.  
  19.                 if (!File.Exists(fullName))
  20.                     return null;
  21.  
  22.                 string bidContents = File.ReadAllText(fullName);
  23.  
  24.                 return JsonConvert.DeserializeObject<Bid>(bidContents);
  25.             }
  26.  
  27.             public void SaveBidders(Bid bidders)
  28.             {
  29.                 string fullName = Path.Combine(_filePath, "Bid.json");
  30.  
  31.                 string biddersContents = JsonConvert.SerializeObject(bidders);
  32.  
  33.                 File.WriteAllText(fullName, biddersContents);
  34.  
  35.             }
  36.  
  37.             public void SaveStartingBid(Bid bid)
  38.             {
  39.                 throw new NotImplementedException();
  40.             }
  41.     }
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment