public void Update(ShipDTO shipDTO) { //get persisted item var ship = _Repository.Get(shipDTO.Id); if (ship == null) { throw new DataNotFoundException(BaseMessagesResources.Ship_NotExists); } var oldDTO = ship.ToDto(); var current = shipDTO.ToModel(); ship.Name = current.Name; ship.Description = current.Description; if (ship.Name.IsNullOrBlank()) { throw new DefinedException(CommonMessageResources.Name_Empty); } if (_Repository.Exists(ship)) { throw new DataExistsException(string.Format(BaseMessagesResources.Ship_Exists_WithValue, ship.Name)); } #region 操作日志 var shipDto = ship.ToDto(); OperateRecorder.RecordOperation(shipDto.Sn, BaseMessagesResources.Update_Ship, shipDto.GetOperationLog(oldDTO)); #endregion //commit unit of work _Repository.UnitOfWork.Commit(); }
public async Task <IEnumerable <ShipListResource> > Get() { return(await repo.Get()); }