Exemplo n.º 1
0
        public async Task <IActionResult> EditTelephone(TelephoneDetailAC telephoneDetailAC)
        {
            string userId   = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "user_id").Value;
            string fullname = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "fullname").Value;

            return(Ok(await _iTelephoneRepository.UpdateTelephone(Convert.ToInt64(userId), telephoneDetailAC, fullname)));
        }
Exemplo n.º 2
0
        public HttpResponseMessage UpdateCellphone(string beforeTelephone, TelephoneModel telephoneModel)
        {
            try
            {
                telephoneModel.beforeTelephone = beforeTelephone;

                HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(JsonConvert.SerializeObject(telephoneRepository.UpdateTelephone(telephoneModel)))
                };
                return(hrm);
            }
            catch (Exception ex)
            {
                Errors errors          = ErrorsHelper.GetErrors(ex);
                HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(errors.ToString())
                };
                return(hr);
            }
        }
        public IActionResult UpdateTelephone(string beforeTelephone, TelephoneModel telephoneModel)
        {
            try
            {
                if (telephoneModel == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                telephoneModel.beforeTelephone = beforeTelephone;
                TelephoneModel updatedTelephone = telephoneRepository.UpdateTelephone(telephoneModel);
                return(Ok(updatedTelephone));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage UpdateTelephone(string beforeTelephone, TelephoneModel telephoneModel)
        {
            try
            {
                if (telephoneModel == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
                }

                telephoneModel.beforeTelephone = beforeTelephone;
                TelephoneModel updatedTelephone = telephoneRepository.UpdateTelephone(telephoneModel);
                return(Request.CreateResponse(HttpStatusCode.OK, updatedTelephone));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
            }
        }