public override void OnActionExecuting(ActionExecutingContext context) { var state = context.ModelState; if (!state.IsValid) { var errors = state.Keys .Where(k => state[k].Errors.Count > 0) .Select( k => new { propertyName = k, errorMessage = CollectMessages(state[k].Errors) } ); var responseEntityBuilder = new ResponseEntityBuilder <object>() { Data = errors, ErrorCode = 1, ResponseStatusCode = HttpStatusCode.BadRequest }; context.Result = responseEntityBuilder.Build(); } }
public ResponseEntity <ResponseData <object> > Delete(int companyId) { _companyService.Delete(companyId, 1); var responseEntityBuilder = new ResponseEntityBuilder <object>(); return(responseEntityBuilder.Build()); }
public ResponseEntity <ResponseData <object> > Post([FromForm] PostRequest request) { _stackService.Create(RequestMapperService.MapToEntity(request, DateTime.Now, 1)); var responseEntityBuilder = new ResponseEntityBuilder <object> { ResponseStatusCode = HttpStatusCode.Created }; return(responseEntityBuilder.Build()); }
public ResponseEntity <ResponseData <RecursiveGetResponse> > Get(int companyId) { var responseEntityBuilder = new ResponseEntityBuilder <RecursiveGetResponse> { Data = new RecursiveGetResponse { RecursiveStacks = _stackService.RecursiveSearch(companyId) } }; return(responseEntityBuilder.Build()); }
public ResponseEntity <ResponseData <GetResponse> > Get(int companyId, [FromQuery] GetQParams getQParams) { var responseEntityBuilder = new ResponseEntityBuilder <GetResponse> { Data = new GetResponse { Company = _companyService.Get(companyId), RequestRelationIds = getQParams.RequestRelationIds } }; return(responseEntityBuilder.Build()); }
public ResponseEntity <ResponseData <ListResponse> > Get() { List <Company> companies = _companyService.Search(); var responseEntityBuilder = new ResponseEntityBuilder <ListResponse> { Data = new ListResponse { Companies = companies } }; return(responseEntityBuilder.Build()); }
public ResponseEntity <ResponseData <object> > Post([FromForm] CompanyCompositePostRequest compositeRequest) { var now = DateTime.Now; _companyService.Create( RequestMapperService.MapToEntity(compositeRequest.Company, now, 1), RequestMapperService.MapToEntity(compositeRequest.Address, now, 1) ); var responseEntityBuilder = new ResponseEntityBuilder <object>() { ResponseStatusCode = HttpStatusCode.Created }; return(responseEntityBuilder.Build()); }