Exemple #1
0
        public async Task <IActionResult> Post([FromBody] FilterModel model)
        {
            if (model == null || !ModelState.IsValid)
            {
                throw new ApiException("Model error encountered", HttpStatusCode.BadRequest, ModelState);
            }

            var result = await service.Create(model.ToEntity(this.User.GetUserId()));

            return(Created(Url.Link(RouteConstants.FilterSelfRoute, new { id = result.Id }), result));
        }
Exemple #2
0
        public async Task <ActionResult> Create(FilterViewModel filterViewModel)
        {
            if (ModelState.IsValid)
            {
                var filterDto        = filterViewModelFactory.CreateFilterDto(filterViewModel);
                var operationDetails = await filterService.Create(filterDto);

                if (operationDetails.Succeeded)
                {
                    return(RedirectToAction("Dashboard", "Filter"));
                }
                ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
            }
            return(View(filterViewModel));
        }