public AssignRolesToUserOutput AssignRolesToUser(AssignRolesToUserInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/accounts/assignRolesToUser", RestSharp.Method.POST); req.AddHeader("Content-Type", "application/json"); req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.AddJsonBody(input); var response = http.HttpPost <object>(req); AssignRolesToUserOutput output = new AssignRolesToUserOutput(); output.Id = JsonConvert.DeserializeObject <string>(response.ToString()); return(output); } catch (Exception ex) { WriteLogFile.Append("AssignRolesToUser : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
public UpdateUserInfoOutput UpdateUserInfo(UpdateUserInfoInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = null; if (!string.IsNullOrEmpty(input.Id)) { req = new RestRequest("api/accounts/update", RestSharp.Method.POST); } req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.RequestFormat = DataFormat.Json; req.AddJsonBody(input); var response = http.HttpPost <UpdateUserInfoOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("UpdateUserInfo : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(default(UpdateUserInfoOutput)); } }
//Public Methods public GetAllRolesOutput GetAllRoles(GetAllRolesInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/roles", RestSharp.Method.POST); req.AddHeader("Content-Type", "application/json"); req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.AddJsonBody(input); RestSharp.RestClient client = new RestSharp.RestClient(WebConfigurationManager.AppSettings["AuthServerAPI"]); var response = client.Execute <List <RoleModel> >(req); List <RoleModel> result = JsonConvert.DeserializeObject <List <RoleModel> >(response.Content); GetAllRolesOutput output = new GetAllRolesOutput(); output.Roles = result; return(output); } catch (Exception ex) { WriteLogFile.Append("GetAllRoles : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
public GetAllUsersOutput GetAllUsers(GetAllUsersInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = null; req = new RestRequest("api/accounts/users", RestSharp.Method.POST); req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.RequestFormat = DataFormat.Json; RestSharp.RestClient client = new RestSharp.RestClient(WebConfigurationManager.AppSettings["AuthServerAPI"]); var response = client.Execute <GetAllUsersOutput>(req); GetAllUsersOutput output = new GetAllUsersOutput(); output.Users = JsonConvert.DeserializeObject <List <GetUserInfoModel> >(response.Content, new ClaimConverter()); return(output); } catch (Exception ex) { WriteLogFile.Append("GetAllUsers : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(default(GetAllUsersOutput)); } }
public GetAllMedicalProfilesByUserIdOutput GetAllMedicalProfilesByUserId(GetAllMedicalProfilesByUserIdInput input) { GetAllMedicalProfilesByUserIdOutput outputToReturn = new GetAllMedicalProfilesByUserIdOutput(); try { var medicalProfiles = _medicalProfileRepository.GetMedicalProfileByUserId(input.UserId); if (medicalProfiles != null && medicalProfiles.Any()) { outputToReturn.MedicalProfiles = new List <MedicalProfileModel>(); foreach (var entity in medicalProfiles) { MedicalProfileModel model = new MedicalProfileModel(); model.Id = entity.Id; model.UserId = entity.UserID; model.FirstName = entity.FirstName; model.LastName = entity.LastName; model.GenderSD = entity.GenderSD; model.MaritalStatusSD = entity.MaritalStatusSD; model.Age = entity.Age; model.BloodType = entity.BloodTypeSD; model.WeightSD = entity.WeightSD; model.HeightSD = entity.HeightSD; model.Occupation = entity.Occupation; model.HaveInsurance = entity.HaveInsurance; model.HaveNSSF = entity.HaveNSSF; model.Smoker = entity.Smoker; model.HaveChildren = entity.HaveChildren; model.CaffeineDrinker = entity.CaffeineDrinker; model.CaffeinePerDay = entity.CaffeinePerDay; model.TakeMedication = entity.TakeMedication; model.HavePreviousSurgeries = entity.HavePreviousSurgeries; model.HaveMedicationAllergy = entity.HaveMedicationAllergy; model.HaveOtherAllergy = entity.HaveOtherAllergy; model.FamilyMedicalHistory = entity.FamilyMedicalHistory; outputToReturn.MedicalProfiles.Add(model); } } return(outputToReturn); } catch (Exception ex) { WriteLogFile.Append("GetAllMedicalProfilesByUserId : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(null); } }
public GetMedicalProfileOutput GetMedicalProfile(GetMedicalProfileInput input) { GetMedicalProfileOutput outputToReturn = new GetMedicalProfileOutput(); try { MedicalProfile medicalProfile = _medicalProfileRepository.GetMedicalProfileById(input.Id); if (medicalProfile != null) { outputToReturn.MedicalProfile = new MedicalProfileModel(); MedicalProfileModel model = new MedicalProfileModel(); model.Id = medicalProfile.Id; model.UserId = medicalProfile.UserID; model.FirstName = medicalProfile.FirstName; model.LastName = medicalProfile.LastName; model.GenderSD = medicalProfile.GenderSD; model.MaritalStatusSD = medicalProfile.MaritalStatusSD; model.Age = medicalProfile.Age; model.BloodType = medicalProfile.BloodTypeSD; model.WeightSD = medicalProfile.WeightSD; model.HeightSD = medicalProfile.HeightSD; model.Occupation = medicalProfile.Occupation; model.HaveInsurance = medicalProfile.HaveInsurance; model.HaveNSSF = medicalProfile.HaveNSSF; model.Smoker = medicalProfile.Smoker; model.HaveChildren = medicalProfile.HaveChildren; model.CaffeineDrinker = medicalProfile.CaffeineDrinker; model.CaffeinePerDay = medicalProfile.CaffeinePerDay; model.TakeMedication = medicalProfile.TakeMedication; model.HavePreviousSurgeries = medicalProfile.HavePreviousSurgeries; model.HaveMedicationAllergy = medicalProfile.HaveMedicationAllergy; model.HaveOtherAllergy = medicalProfile.HaveOtherAllergy; model.FamilyMedicalHistory = medicalProfile.FamilyMedicalHistory; } return(outputToReturn); } catch (Exception ex) { WriteLogFile.Append("GetMedicalProfile : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(null); } }
// add new medical record by current user public CreateMedicalProfileOutput CreateMedicalProfile(CreateMedicalProfileInput input) { CreateMedicalProfileOutput outputToReturn = new CreateMedicalProfileOutput(); try { MedicalProfile medicalProfile = new MedicalProfile(); medicalProfile.UserID = _apiSession.CurrentUserID; medicalProfile.FirstName = input.FirstName; medicalProfile.LastName = input.LastName; medicalProfile.GenderSD = input.GenderSD; medicalProfile.MaritalStatusSD = input.MaritalStatusSD; medicalProfile.Age = input.Age; medicalProfile.BloodTypeSD = input.BloodType; medicalProfile.WeightSD = input.WeightSD; medicalProfile.HeightSD = input.HeightSD; medicalProfile.Occupation = input.Occupation; medicalProfile.HaveInsurance = input.HaveInsurance; medicalProfile.HaveNSSF = input.HaveNSSF; medicalProfile.Smoker = input.Smoker; medicalProfile.HaveChildren = input.HaveChildren; medicalProfile.CaffeineDrinker = input.CaffeineDrinker; medicalProfile.CaffeinePerDay = input.CaffeinePerDay; medicalProfile.TakeMedication = input.TakeMedication; medicalProfile.HavePreviousSurgeries = input.HavePreviousSurgeries; medicalProfile.HaveMedicationAllergy = input.HaveMedicationAllergy; medicalProfile.HaveOtherAllergy = input.HaveOtherAllergy; medicalProfile.FamilyMedicalHistory = input.FamilyMedicalHistory; medicalProfile.CreateUserID = _apiSession.CurrentUserID; medicalProfile.DateCreated = DateTime.UtcNow; long Id = _medicalProfileRepository.CreateMedicalProfile(medicalProfile); outputToReturn.Id = Id; outputToReturn.ReturnStatus.OK(); return(outputToReturn); } catch (Exception ex) { WriteLogFile.Append("CreateMedicalProfile : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(null); } }
//Public Methods public RegisterUserOutput RegisterUser(RegisterUserInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/accounts/create", RestSharp.Method.POST); req.AddJsonBody(input); RegisterUserOutput response = http.HttpPost <RegisterUserOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("RegisterUser : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
public ForgotPasswordOutput ForgotPassword(ForgotPasswordInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/accounts/ForgotPassword", RestSharp.Method.POST); req.AddHeader("Content-Type", "application/json"); req.AddJsonBody(input); ForgotPasswordOutput response = http.HttpPost <ForgotPasswordOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("ForgotPassword : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
public DeleteMedicalProfileOutput DeleteMedicalProfile(DeleteMedicalProfileInput input) { DeleteMedicalProfileOutput outputToReturn = new DeleteMedicalProfileOutput(); try { long recordDeletedId = outputToReturn.Id = _medicalProfileRepository.DeleteMedicalProfile(input.Id); outputToReturn.Id = recordDeletedId; outputToReturn.ReturnStatus.OK(); return(outputToReturn); } catch (Exception ex) { WriteLogFile.Append("DeleteMedicalProfile : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(null); } }
public ChangePasswordOutput ChangePassword(ChangePasswordInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/accounts/ChangePassword", RestSharp.Method.POST); req.AddHeader("Content-Type", "application/json"); req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.AddJsonBody(input); ChangePasswordOutput response = http.HttpPost <ChangePasswordOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("ConfirmPassword : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
public DeleteUserOutput DeleteUser(DeleteUserInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/accounts/delete", RestSharp.Method.DELETE); req.AddHeader("Content-Type", "application/json"); req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.AddJsonBody(input); DeleteUserOutput response = http.HttpPost <DeleteUserOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("DeleteUser : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
public UpdateRoleOutput UpdateRole(UpdateRoleInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = new RestRequest("api/roles/update", RestSharp.Method.POST); req.AddHeader("Content-Type", "application/json"); req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.AddJsonBody(input); UpdateRoleOutput response = http.HttpPost <UpdateRoleOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("UpdateRole : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); } return(null); }
//testing git private void Init() { BaseInit(); WriteLogFile.Append("Init between"); _medicalProfileSvc = new MedicalProfileService(ApiSession); }