public async Task <IActionResult> UpdateCardByIdAsync(string collectionName,
                                                              [FromBody] View.CardsCollectionPatchInfo updateInfo, CancellationToken cancellationToken)
        {
            try
            {
                Guid.TryParse(HttpContext.User.Identity.Name, out var userId);

                if (!await collectionService.IsNameExistAsync(collectionName, userId))
                {
                    return(BadRequest(new { message = "No collection with name \"" + collectionName + "\"" }));
                }

                var collection = CardsCollectionConverter.ConvertPatchInfo(updateInfo);
                collectionService.UpdateByIdAsync(collection, collectionName, userId);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateCardByIdAsync(string id,
                                                              [FromBody] View.CardsCollectionPatchInfo updateInfo, CancellationToken cancellationToken)
        {
            try
            {
                Guid.TryParse(HttpContext.User.Identity.Name, out var userId);
                Guid.TryParse(id, out var collectionId);

                if (!await collectionService.IsIdExistAsync(collectionId, userId))
                {
                    return(BadRequest(new { message = "Нет коллекции с указанным идентификатором" }));
                }

                var collection = CardsCollectionConverter.ConvertPatchInfo(updateInfo);
                collectionService.UpdateByIdAsync(collection, collectionId, userId);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }