Beispiel #1
0
        public Category Update(UpdateCmd command)
        {
            Category result = null;

            if (command.IsValid())
            {
                result = _categoryRepository.GetById(command.Id);

                if (!_categoryRepository.Notification.HasNotifications)
                {
                    command.Apply(ref result);
                    _categoryRepository.Add(result);
                }

                if (_categoryRepository.Notification.HasNotifications)
                {
                    Notification.AddNotifications(_categoryRepository.Notification.Notifications);
                }
            }
            else
            {
                command.Undo(ref result);
                Notification.AddNotifications(command.Validation);
            }

            return(result);
        }
        public async Task <IActionResult> PutMovie(Guid id, UpdateCmd comando)
        {
            if (id != comando.Id)
            {
                return(BadRequest());
            }

            //_context.Entry(movie).State = EntityState.Modified;

            try
            {
                this._notificationContext.Clear();

                if (!comando.IsValid())
                {
                    this._notificationContext.AddNotifications(comando.ValidationResult);
                    return(CreatedAtAction("GetMovie", comando));
                }


                //await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MovieExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }