public async Task <IActionResult> Get() { //List<ProductPromo> //var result = await _adapter.GetData("PromoDatabase", "PromoCollection"); var result = await _adapter.GetData("PromoDatabase", "PromoCollection"); //new System.Linq.SystemCore_EnumerableDebugView<object>(result).Items ResponseObject responseobject = new ResponseObject(); // promotions = result; responseobject.correlationalId = Guid.NewGuid().ToString(); responseobject.statusCode = 200; responseobject.statusReason = "OK"; responseobject.success = true; responseobject.promotions = result; return(Ok(responseobject)); // var list = JsonConvert.DeserializeObject<List<ProductPromo>>(result); /* productpromo = result; * ResponseObject responseobject = new ResponseObject(); * List<ProductPromo> prmoList = new List<ProductPromo>(); * * responseobject.correlationalId = Guid.NewGuid().ToString(); * responseobject.statusCode = 200; * responseobject.statusReason = "OK"; * responseobject.success = true; * * responseobject.promotions = result;*/ return(Ok(result)); }
public async Task <IActionResult> Delete() { ResponseObject responseobject = new ResponseObject(); try { List <ProductPromo> promos = await _adapter.GetData("PromoDatabase", "PromoCollection"); string indexValue = ""; if (Request.Headers.ContainsKey("ids")) { indexValue = Request.Headers["ids"].First(); string[] indexValuesArray = indexValue.Split(","); foreach (var promo in promos.ToList()) { bool present = indexValuesArray.Contains(promo.Id); if (present) { var result = await _adapter.updateDocumentAsyncResponse("PromoDatabase", "PromoCollection", promo); promos.Remove(promo); } } } // responseobject.promotions = promos; List <ProductPromo> promotions = responseobject.promotions; responseobject.correlationalId = Guid.NewGuid().ToString(); responseobject.statusCode = 202; responseobject.statusReason = "Accepted"; responseobject.success = true; return(Ok(responseobject)); } catch (Exception ex) { responseobject.correlationalId = Guid.NewGuid().ToString(); responseobject.statusCode = 500; responseobject.statusReason = "Internal Server Error"; responseobject.success = false; return(StatusCode(StatusCodes.Status500InternalServerError, responseobject)); } }
public async Task <IActionResult> Get() { var result = await _adapter.GetData("PromoDatabase", "PromoCollection"); return(Ok(result)); }
public async Task <IActionResult> Get() { var result = await _adapter.GetData("test-db", "test-collection"); return(Ok(result)); }