Пример #1
0
        public async Task <IActionResult> EditCollection([FromBody] EditCollectionInput model)
        {
            try
            {
                var result = await collectionLib.EditCollectionAsync(model, CurrentUserId);

                return(CustomResult(result));
            }
            catch (System.Exception exp)
            {
                return(CustomError(exp));
            }
        }
Пример #2
0
        public async Task <CollectionModel> EditCollectionAsync(EditCollectionInput model, long currentUserId)
        {
            var entity = await collectionMovieRepo.FirstAsync(x =>
                                                              x.Id == model.Id &&
                                                              x.UserId == currentUserId);

            if (entity == null)
            {
                throw new System.Exception("Collection is not exist");
            }

            entity.Name = model.Name;

            collectionMovieRepo.Update(entity);

            await unitOfWork.CommitAsync();

            return(ConvertEntityToCollectionModel(entity));
        }