public async Task <ActionResult> CreateAsync([FromBody] SalesOrder_CreateInput _data) { ActionResult response; try { if (ModelState.IsValid) { Output <SalesOrder_CreateOutput> output = await svc.CreateAsync(_data); response = StatusCode((int)output.HttpStatus, output); return(response); } else { currentErrors.AddModelErrors(ModelState); } } catch (Exception ex) { currentErrors.MergeWith(errorsParser.FromException(ex)); } response = StatusCode((int)currentErrors.HttpStatus, new Output(currentErrors)); return(response); }
public async Task <IActionResult> CreateOrderAsync(SalesOrderForCreate model) { if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage).ToList(); return(BadRequest(new ErrorResponse(HttpStatusCode.BadRequest, "Validation error", errors))); } var result = await _salesOrderService.CreateAsync(model); return(result.Succeed ? Ok() : BadRequest(new ErrorResponse(HttpStatusCode.BadRequest, "Create fail", result.Errors))); }
public async Task <IActionResult> OnPostAsync() { try { ConvertData(SalesOrder); var insertedCount = await _salesOrderService.CreateAsync(SalesOrder); } catch (Exception e) { return(GenJsonResult(-1, e.Message, 0)); } return(GenJsonResult(1, "", SalesOrder.SalesOrderID)); }