Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public JsonResult Create(PosDeviceDetailView vm)
        {
            CreatePosDeviceRequest request = new CreatePosDeviceRequest();

            request.BrandId      = vm.BrandId;
            request.SerialNumber = vm.SerialNumber;
            request.Model        = vm.Model;
            CreatePosDeviceResponse response = _posDeviceService.CreatePosDevice(request);

            return(Json(response));
        }