public Service Update(UpdateServiceCommand command) { var service = _repository.GetOne(command.Id); if (!string.IsNullOrEmpty(command.Name)) service.ChangeName(command.Name); if (!string.IsNullOrEmpty(command.Description)) service.changeDescripion(command.Description); service.ChangeValue(command.Value); _repository.Update(service); if (Commit()) return service; return null; }
public Task<HttpResponseMessage> Put([FromBody]dynamic body) { var service = _service.GetOneByName((string)body.name); if (service == null) return CreateResponse(HttpStatusCode.Ambiguous, service); var commandService = new UpdateServiceCommand( id: Guid.Parse((string)body.id), name: (string)body.name, value: (float)body.value, description: (string)body.description ); service = _service.Update(commandService); return CreateResponse(HttpStatusCode.Created, service); }