Ejemplo n.º 1
0
        public AddPhoneResponse AddPhone(AddPhoneRequest request)
        {
            var result      = new ServerAddPhoneResponse();
            var returnValue = result.ProcessRequest(cnn, request);

            return(returnValue);
        }
Ejemplo n.º 2
0
        private DefaultResponse ClientChangePhone(ClientChangeModel model)
        {
            var response = new DefaultResponse();

            try
            {
                AddPhoneRequest request = new AddPhoneRequest
                {
                    ClientID = model.Id,
                    Phone    = Convert.ToInt64(PhoneService.GetPhoneFromStr(model.Phone))
                };
                HttpResponseMessage changeResponse = HttpClientService.PostAsync("api/client/AddPhone", request).Result;
                if (changeResponse.IsSuccessStatusCode)
                {
                    response = changeResponse.Content.ReadAsAsync <DefaultResponse>().Result;
                    return(response);
                }
            }
            catch (Exception e)
            {
                response.ErrorCode = 500;
                response.Message   = e.Message;
            }
            return(response);
        }
Ejemplo n.º 3
0
 public async Task AddPhone(AddPhoneRequest request)
 {
     Phone phone = new Phone
     {
         PhoneName    = request.PhoneName,
         Manufacturer = request.Manufacturer,
         CPUName      = request.CPUName,
         CPUCore      = request.CPUCore,
         Ram          = request.Ram,
         Sim          = request.Sim,
         ScreenWidth  = request.ScreenWidth,
         ScreenHeight = request.ScreenHeight,
         ScreenSize   = request.ScreenSize,
         Resolution   = request.Resolution,
         Rom          = request.Rom,
         Camera       = request.Camera,
         Battery      = request.Battery,
         OS           = request.OS,
         Rating       = request.Rating,
         Image        = request.Image,
         ImagePreview = request.ImagePreview,
         ImageLarge   = request.ImageLarge,
         Price        = request.Price
     };
     await _repository.AddPhone(phone);
 }
Ejemplo n.º 4
0
        public AddPhoneResponse AddPhone(AddPhoneRequest request)
        {
            Log.Information("LCManagerPartner AddPhone {Phone}", request.Phone);
            var result      = new ServerAddPhoneResponse();
            var returnValue = result.ProcessRequest(cnn, request);

            return(returnValue);
        }
Ejemplo n.º 5
0
        private async Task WhenIUpdateUserInfo()
        {
            _request = Fixture.Build <AddPhoneRequest>()
                       .With(x => x.UserId, _userId)
                       .With(x => x.Number, _number)
                       .Create();

            _replay = await Client.AddPhoneAsync(_request);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> AddPhone([FromBody] AddPhoneRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await _service.AddPhone(request);

            return(Ok());
        }
Ejemplo n.º 7
0
        private async Task AndWithPhone()
        {
            _request = Fixture.Build <AddPhoneRequest>()
                       .With(x => x.UserId, _userId)
                       .With(x => x.Number, Fixture.Create <string>().Substring(0, 15))
                       .Create();

            _replay = await Client.AddPhoneAsync(_request);

            _replay.IsSuccess.Should().BeTrue();
            _number = _replay.Value.Number;
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> AddPhone([FromRoute] Guid id, [FromBody] AddPhoneRequest phone)
        {
            _logger.LogInformation("Getting user phone");

            try
            {
                var result = await _service.AddPhoneAsync(id.ToString(), phone.Number)
                             .ConfigureAwait(false);

                return(StatusCode(result.StatusCode, result.Value));
            }
            catch (Exception e)
            {
                _logger.LogCritical(e, "Error to get user phone");
                return(StatusCode(HttpStatusCode.ServiceUnavailable, "UserService down"));
            }
        }
Ejemplo n.º 9
0
        public override async Task <AddPhoneReplay> AddPhone(AddPhoneRequest request, ServerCallContext context)
        {
            var operation = _provider.GetRequiredService <PhoneAddOperation>();
            var mapper    = _provider.GetRequiredService <IMapper <Result, AddPhoneReplay> >();

            if (Guid.TryParse(request.UserId, out var userId))
            {
                var result = await operation.ExecuteAsync(new PhoneAdd
                {
                    UserId = userId,
                    Number = request.Number
                });

                return(mapper.Map(result));
            }

            return(mapper.Map(DomainError.UserError.InvalidUserId));
        }