/// <summary> /// news a account /// </summary> /// <param name="accountDTO"></param> /// <returns></returns> public GooderProudctDTO AddNewProudct(GooderProudctDTO proudctDTO) { //check preconditions if (proudctDTO == null) { throw new ArgumentException(Messages.warning_CannotAddGooderProudctWithEmptyInformation); } var account = _accountRepository.Get(proudctDTO.AccountId); if (account != null) { var product = GooderProudctFactory.CreateGooderProudct(proudctDTO.AccountId, proudctDTO.Name, proudctDTO.SourceCity, proudctDTO.DestCityFrist, proudctDTO.DestCitySecond, proudctDTO.DestCityThird, proudctDTO.CarLength, proudctDTO.CarType, proudctDTO.GooderVolume, proudctDTO.GooderHeight, proudctDTO.LayStartTime, proudctDTO.LayEndTime, proudctDTO.UnitPrice, proudctDTO.Transferway, proudctDTO.Payway, proudctDTO.Remark, proudctDTO.IsRefresh, proudctDTO.Lat, proudctDTO.Lng); //save entity SaveProdect(product, account); //return the data with id and assigned default values return(product.ProjectedAs <GooderProudctDTO>()); } else { return(null); } }
GooderProudct MaterializeAccountFromDto(GooderProudctDTO proudctDTO) { var current = GooderProudctFactory.CreateGooderProudct(proudctDTO.AccountId, proudctDTO.Name, proudctDTO.SourceCity, proudctDTO.DestCityFrist, proudctDTO.DestCitySecond, proudctDTO.DestCityThird, proudctDTO.CarLength, proudctDTO.CarType, proudctDTO.GooderVolume, proudctDTO.GooderHeight, proudctDTO.LayStartTime, proudctDTO.LayEndTime, proudctDTO.UnitPrice, proudctDTO.Transferway, proudctDTO.Payway, proudctDTO.Remark, proudctDTO.IsRefresh, proudctDTO.Lat, proudctDTO.Lng); current.ChangeCurrentIdentity(proudctDTO.Id); return(current); }