protected override async Task <JObject> PerformPost(JObject newObject) { var arr = await FSRepository.Load(Context, RepositoryName); newObject.Add("id", FSRepository.MakeID()); arr.Add(newObject); await FSRepository.Save(Context, RepositoryName, arr); return(newObject); }
protected override async Task <JObject> PerformGet(string id) { var arr = await FSRepository.Load(Context, RepositoryName); var current = arr.FirstOrDefault((dynamic row) => row.id == id) as JObject; if (current == null) { throw new NotFoundException(); } return(current); }
protected override async Task <JArray> PerformQuery(JObject queryParams) { var rows = await FSRepository.Load(Context, RepositoryName); var filter = BuildFilter(queryParams); JArray result = new JArray(); foreach (JObject row in rows) { var jresult = filter(row); if (jresult != null) { result.Add(jresult); } } return(result); }
protected override async Task <JObject> PerformPut(string id, JObject newObject) { await Validate(false, newObject); if (!Context.IsValid) { return(null); } var arr = await FSRepository.Load(Context, RepositoryName); var current = arr.FirstOrDefault((dynamic row) => row.id == id) as JObject; if (current != null) { current.Merge(newObject); await FSRepository.Save(Context, RepositoryName, arr); return(current); } throw new NotFoundException(); }
public OrderController(IMapper mapper, FSRepository rep) { _mapper = mapper; repository = rep; }
public PaymentController(IMapper mapper, FSRepository rep) { _mapper = mapper; repository = rep; }
public UsersController(IMapper mapper, FSRepository rep) { _mapper = mapper; repository = rep; }