public ModifyPosDeviceResponse ModifyPosDevice(ModifyPosDeviceRequest request) { ModifyPosDeviceResponse response = new ModifyPosDeviceResponse(); PosDevice posDevice = _posDeviceRepository .FindBy(request.DeviceId); posDevice.Id = request.DeviceId; posDevice.BrandId = request.BrandId; posDevice.SerialNumber = request.SerialNumber; posDevice.Model = request.Model; posDevice.PosTerminals = request.PosTerminals.ConvertToPosTerminals(); if (posDevice.GetBrokenRules().Count() > 0) { response.Errors = posDevice.GetBrokenRules().ToList(); } else { try { _posDeviceRepository.Save(posDevice); _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 CreatePosDeviceResponse CreatePosDevice(CreatePosDeviceRequest request) { CreatePosDeviceResponse response = new CreatePosDeviceResponse(); PosDevice posDevice = new PosDevice(); posDevice.BrandId = request.BrandId; posDevice.SerialNumber = request.SerialNumber; posDevice.Model = request.Model; posDevice.PosTerminals = request.PosTerminals.ConvertToPosTerminals(); if (posDevice.GetBrokenRules().Count() > 0) { response.Errors = posDevice.GetBrokenRules().ToList(); } else { try { _posDeviceRepository.Add(posDevice); _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); }