コード例 #1
0
        public IActionResult Create(CreateAreaModel model)
        {
            var validationResult = _service.ValidateCreateArea(User, model);

            if (!validationResult.Valid)
            {
                return(BadRequest(validationResult.Result));
            }
            var entity = _service.CreateArea(model);

            context.SaveChanges();
            return(Created($"/{ApiEndpoint.AREA_API}?id={entity.Id}",
                           new AppResultBuilder().Success(entity.Id)));
        }
コード例 #2
0
        public async Task <IHttpActionResult> CreateArea(AreaCreate area)
        {
            //check if model is valid
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //instantiate area service
            AreaService service = CreateAreaService();

            if (await service.CreateArea(area) == false)
            {
                return(InternalServerError());
            }

            return(Ok()); //200
        }