Пример #1
0
        public async Task <ActionResult> Edit(string id, [FromBody] VideoCategoryRequest model)
        {
            var response = await _service.VideoCategoryUpdateResponse(id, model);

            if (!response.Success)
            {
                return(NotFound(response.Message));
            }

            return(Ok(response.Message));
        }
Пример #2
0
        public async Task <ServiceResponse <int> > VideoCategoryUpdateResponse(string id, VideoCategoryRequest model)
        {
            var entity = await Context.VideoCategories.FindAsync(id);

            if (entity == null)
            {
                return(ServiceResponse <int> .Error(new ErrorMessage("Resource not exist")));
            }
            entity.Name = model.Name;
            Context.Update(entity);
            var numberOfChanges = await Context.SaveChangesAsync();

            return(ServiceResponse <int> .Ok(numberOfChanges, new ErrorMessage("Video Category Updated")));
        }