/// <summary> /// news a account /// </summary> /// <param name="accountDTO"></param> /// <returns></returns> public AccountDTO AddNewAccount(AccountDTO accountDTO) { //check preconditions if (accountDTO == null) { throw new ArgumentException(Messages.warning_CannotAddCustomerWithEmptyInformation); } var user = _accountRepository.Get(accountDTO.Mobile); if (user == null) { //Create the entity and the required associated data var gooder = new GooderAuthInfo(accountDTO.GooderAuthInfo_RealName, accountDTO.GooderAuthInfo_CardNo, accountDTO.GooderAuthInfo_CardNoUrl, accountDTO.GooderAuthInfo_HeadUrl, accountDTO.GooderAuthInfo_ComparyName, accountDTO.GooderAuthInfo_ComparyCity, accountDTO.GooderAuthInfo_ComparyAddress, accountDTO.GooderAuthInfo_BusinesslicenseUrl); var driver = new DriverAuthInfo(accountDTO.DriverAuthInfo_RealName, accountDTO.DriverAuthInfo_CardNo, accountDTO.DriverAuthInfo_HeadUrl, accountDTO.DriverAuthInfo_CarType, accountDTO.DriverAuthInfo_CarLength, accountDTO.DriverAuthInfo_CarNo, accountDTO.DriverAuthInfo_CarHeight, accountDTO.DriverAuthInfo_CarBrand, accountDTO.DriverAuthInfo_CarYear, accountDTO.DriverAuthInfo_DriverLicenceUrl, accountDTO.DriverAuthInfo_CarVehicleUrl); var location = new Location(accountDTO.CarLocation_Lng, accountDTO.CarLocation_Lat, accountDTO.CarLocation_LocationUpdateTime); var account = AccountFactory.CreateAccount(accountDTO.Mobile, accountDTO.PassWord, (UserType)accountDTO.UserType, driver, gooder, location); //save entity SaveAccount(account); //return the data with id and assigned default values return(account.ProjectedAs <AccountDTO>()); } else { return(null); } }
Account MaterializeAccountFromDto(AccountDTO accountDTO) { var gooder = new GooderAuthInfo(accountDTO.GooderAuthInfo_RealName, accountDTO.GooderAuthInfo_CardNo, accountDTO.GooderAuthInfo_CardNoUrl, accountDTO.GooderAuthInfo_HeadUrl, accountDTO.GooderAuthInfo_ComparyName, accountDTO.GooderAuthInfo_ComparyCity, accountDTO.GooderAuthInfo_ComparyAddress, accountDTO.GooderAuthInfo_BusinesslicenseUrl); var driver = new DriverAuthInfo(accountDTO.DriverAuthInfo_RealName, accountDTO.DriverAuthInfo_CardNo, accountDTO.DriverAuthInfo_HeadUrl, accountDTO.DriverAuthInfo_CarType, accountDTO.DriverAuthInfo_CarLength, accountDTO.DriverAuthInfo_CarNo, accountDTO.DriverAuthInfo_CarHeight, accountDTO.DriverAuthInfo_CarBrand, accountDTO.DriverAuthInfo_CarYear, accountDTO.DriverAuthInfo_DriverLicenceUrl, accountDTO.DriverAuthInfo_CarVehicleUrl); var location = new Location(accountDTO.CarLocation_Lng, accountDTO.CarLocation_Lat, accountDTO.CarLocation_LocationUpdateTime); var current = AccountFactory.CreateAccount(accountDTO.Mobile, accountDTO.PassWord, (UserType)accountDTO.UserType, driver, gooder, location); current.ChangeCurrentIdentity(accountDTO.Id); return(current); }