internal Knight Edit(Knight updated) { Knight data = GetById(updated.Id); data.Name = updated.Name != null ? updated.Name : data.Name; data.Title = updated.Title != null ? updated.Title : data.Title; data.Weapon = updated.Weapon != null ? updated.Weapon : data.Weapon; data.IsAlive = updated.IsAlive; return(_repo.Edit(data)); }
internal Knight Edit(Knight update) { var exists = _repo.GetById(update.Id); if (exists == null) { throw new Exception("Invalid Id"); } _repo.Edit(update); return(update); }
internal Knight Edit(Knight updated) { Knight previous = GetOne(updated.Id); previous.Name = updated.Name.Length > 0 ? updated.Name : previous.Name; if (_repository.Edit(previous)) { return(previous); } throw new Exception("An error has occured when retrieving the data or updating it"); }