public async Task <IActionResult> Get(string id) { ResponseObject responseobject = new ResponseObject(); try { var result = await _adapter.GetDataById("PromoDatabase", "PromoCollection", id); productpromo = result; responseobject.correlationalId = Guid.NewGuid().ToString(); responseobject.statusCode = 200; responseobject.statusReason = "OK"; responseobject.success = true; responseobject.promotion = productpromo; return(Ok(responseobject)); } catch (Exception ex) { // ResponseObject responseobject = new ResponseObject(); 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(string id) { // ProductPromo productpromo = new ProductPromo() ; var result = await _adapter.GetDataById("PromoDatabase", "PromoCollection", id); return(Ok(result)); }
public async Task <IActionResult> CreateDocumentCondition(string id, [FromBody] ProductPromoCondition productPromoCondition) { ResponseObject responseobject = new ResponseObject(); try { ProductPromo productPromo = await _adapter.GetDataById("PromoDatabase", "PromoCollection", id); if (productPromo.conditions == null) { List <ProductPromoCondition> newList = new List <ProductPromoCondition>(); newList.Add(productPromoCondition); productPromo.conditions = newList; } else { productPromo.conditions.Add(productPromoCondition); } var result = await _adapter.CreateDocumentCondition("PromoDatabase", "PromoCollection", productPromo); responseobject.correlationalId = Guid.NewGuid().ToString(); responseobject.statusCode = 201; responseobject.statusReason = "Created"; responseobject.success = true; return(StatusCode(StatusCodes.Status201Created, responseobject)); } catch (Exception ex) { responseobject.correlationalId = Guid.NewGuid().ToString(); responseobject.statusCode = 400; responseobject.statusReason = "Bad Request"; responseobject.success = false; return(StatusCode(StatusCodes.Status400BadRequest, responseobject)); } }