public ModifyPosAddressResponse ModifyPosAddress(ModifyPosAddressRequest request) { ModifyPosAddressResponse response = new ModifyPosAddressResponse(); PosAddress posAddress = _posAddressRepository .FindBy(request.AddressId); posAddress.Id = request.AddressId; posAddress.Address = request.Address; posAddress.PosMerchants = request.PosMerchants.ConvertToPosMerchants(); if (posAddress.GetBrokenRules().Count() > 0) { response.Errors = posAddress.GetBrokenRules().ToList(); } else { try { _posAddressRepository.Save(posAddress); _uow.Commit(); response.Errors = new List <BusinessRule>(); } catch (Exception ex) { response.Errors = new List <BusinessRule>(); response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); } } return(response); }
public CreatePosAddressResponse CreatePosAddress(CreatePosAddressRequest request) { CreatePosAddressResponse response = new CreatePosAddressResponse(); PosAddress posAddress = new PosAddress(); posAddress.Address = request.Address; posAddress.PosMerchants = request.PosMerchants.ConvertToPosMerchants(); if (posAddress.GetBrokenRules().Count() > 0) { response.Errors = posAddress.GetBrokenRules().ToList(); } else { try { _posAddressRepository.Add(posAddress); _uow.Commit(); response.Errors = new List <BusinessRule>(); } catch (Exception ex) { List <BusinessRule> errors = new List <BusinessRule>(); do { errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); ex = ex.InnerException; } while (ex != null); response.Errors = errors; } } return(response); }