/// <summary> /// Devuelve los registros de un usuario logado en la plataforma /// </summary> /// <param name="uiPerson"></param> /// <returns></returns> public async Task <ValidationModel> GetUserApp(Guid uiPerson) { try { UserAppResponse _response = new UserAppResponse(); var securityUser = _iunitOfWork.SecurityUserRepository.FindAllAsync(x => x.UID_PERSON == uiPerson).Result.FirstOrDefault(); var person = await _iunitOfWork.PersonPersonRepository.FindAsync(x => x.UID == uiPerson); if (securityUser != null) { _response.email = securityUser.Username; _response.idRool = securityUser.UID_PROFILE != null ? securityUser.UID_PROFILE.Value : Guid.Empty; _response.uiPerson = securityUser.UID; _response.uicompany = securityUser.UID_COMPANY; _response.NombreCompleto = person.Nombre + " " + person.Apellidos; _response.Foto = string.IsNullOrEmpty(person.Foto) ? "profile.jpg" : person.Foto + ".jpg"; //_response.Foto = "assets/images/avatars/arena_simple.jpg"; } return(await Task.Run(() => _response)); // return _response; } catch (CError e) { var sparameters = "uiPerson : " + uiPerson.ToString(); var jsonModel = JsonConvert.SerializeObject(sparameters); throw _errorManager.AddError("GetUserApp", "UserService_GetUserApp", e, MethodBase.GetCurrentMethod(), jsonModel); } catch (System.Exception ex) { var sparameters = "uiPerson : " + uiPerson.ToString(); var jsonModel = JsonConvert.SerializeObject(sparameters); throw _errorManager.AddError("Error Generico", "UserService_GetUserApp", ex, MethodBase.GetCurrentMethod(), jsonModel); } }
/// <summary> /// Modificacion de los datos de un usuario logado /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <ValidationModel> SetUserApp(SetUserAppRequest request) { try { UserAppResponse userAppResponse = new UserAppResponse(); var _aspUser = await _userManager.FindByIdAsync(request.uiPerson); if (_aspUser != null) { _aspUser.UserName = request.email; _aspUser.NormalizedEmail = request.email; _aspUser.Email = request.email; _aspUser.NormalizedEmail = request.email; await _userManager.UpdateAsync(_aspUser); var _securitUser = await _iunitOfWork.SecurityUserRepository.FindAsync(x => x.UID == Guid.Parse(_aspUser.Id)); if (_securitUser != null) { _securitUser.UID_PROFILE = Guid.Parse(request.idRool); _securitUser.Username = request.email; await _iunitOfWork.SecurityUserRepository.UpdateAsync(_securitUser); } return(new UserAppResponse() { email = _aspUser.Email, idRool = _securitUser.UID_PROFILE.Value, uicompany = _securitUser.UID_COMPANY, uiPerson = _securitUser.UID_PERSON }); } return(userAppResponse); } catch (CError e) { var jsonModel = JsonConvert.SerializeObject(request); throw _errorManager.AddError("SetUserApp", "UserService_SetUserApp", e, MethodBase.GetCurrentMethod(), jsonModel); } catch (System.Exception ex) { var jsonModel = JsonConvert.SerializeObject(request); throw _errorManager.AddError("Error metodo SetUserApp", "UserService_SetUserApp", ex, MethodBase.GetCurrentMethod(), jsonModel); } }