示例#1
0
        public async Task <CatalogsResponse> RunAsync(Guid catalogofcatalogsId)
        {
            CatalogsResponse response = await _context.Catalogs
                                        .ProjectTo <CatalogsResponse>()
                                        .FirstOrDefaultAsync(p => p.Id == catalogofcatalogsId);

            return(response);
        }
示例#2
0
        public async Task <IActionResult> UpdateCatalogs(Guid catalogofcatalogsId, UpdateCatalogsRequest catalogofcatalogs, [FromServices] IUpdateCatalogsCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                CatalogsResponse response = await command.ExecuteAsync(catalogofcatalogsId, catalogofcatalogs);

                return(CreatedAtRoute("GetSingleCatalogs", new { catalogofcatalogsId = response.Id }, response));
            }
            catch (CannotCreateCatalogsExeption exception)
            {
                foreach (var error in exception.Errors)
                {
                    ModelState.AddModelError(exception.Message, error.Description);
                }
                return(BadRequest(ModelState));
            }
        }
示例#3
0
        public async Task <IActionResult> GetCatalogsAsync(Guid catalogofcatalogsId, [FromServices] ICatalogsQuery query)
        {
            CatalogsResponse response = await query.RunAsync(catalogofcatalogsId);

            return(response == null ? (IActionResult)NotFound() : Ok(response));
        }