public static async Task <bool> MilestonesDo() { IMilestoneRepository milestoneRepository = DI.ServiceProvider.GetServiceInstance <IMilestoneRepository>(); IAmazonS3ImageProvider amazonS3ImageProvider = DI.ServiceProvider.GetServiceInstance <IAmazonS3ImageProvider>(); foreach (Mdls.Milestone milestone in await milestoneRepository.GetAll()) { if (milestone.Image != null && milestone.Image.StartsWith("data:image/png;base64,")) { string path = await amazonS3ImageProvider.Add($"{milestone.UserId}/{milestone.id}/img.png", milestone.Image); bool saved = await milestoneRepository.SetImage(milestone.id, path); } } return(true); }
public static async Task <bool> UsersDo() { IUserRepository userRepository = DI.ServiceProvider.GetServiceInstance <IUserRepository>(); IAmazonS3ImageProvider amazonS3ImageProvider = DI.ServiceProvider.GetServiceInstance <IAmazonS3ImageProvider>(); foreach (Mdls.User user in await userRepository.GetAll()) { if (user.Image != null && user.Image.StartsWith("data:image/png;base64,")) { string path = await amazonS3ImageProvider.Add($"users/{user.id}/profile.png", user.Image); bool saved = await userRepository.UpdateImage(user.id, user.Image); } } return(true); }
public async Task <ActionResponse> Add([FromBody] Mdls.Milestone milestone) { milestone.UserId = currentAuthenticationContext.CurrentUser; string milestoneId = await milestoneRepository.Add(milestone); if (milestone.Image != null && milestone.Image.StartsWith("data:image/png;base64,")) { string path = await amazonS3ImageProvider.Add($"milestones/{milestone.UserId}/{milestoneId}/img.png", milestone.Image); bool saved = await milestoneRepository.SetImage(milestoneId, path); } return(new ActionResponse() { State = !String.IsNullOrEmpty(milestoneId) }); }
public async Task <ActionResponse> UpdateImage([FromBody] ImageEdit imageRequest) { string userId = authenticationCurrentContext.CurrentUser; if (imageRequest.Image != null && imageRequest.Image.StartsWith("data:image/png;base64,")) { string path = await amazonS3ImageProvider.Add($"users/{userId}/profile.png", imageRequest.Image); imageRequest.Image = path; } bool updated = await userRepository.UpdateImage(userId, imageRequest.Image); return(new ActionResponse { State = updated }); }
public async Task <IActionResult> Complete([FromBody] DTOs.InviteCompletion completionRequest) { ActionResponse actionResponse = new ActionResponse() { State = false }; //check if inviation is active Mdls.Invite invite = await inviteRepository.Get(completionRequest.InvitationId); if (invite.InviteStatus == Mdls.InviteStatus.Pending) { string encryptedPassword = encryptionProvider.Encrypt(completionRequest.User.Password); string encryptionKey = encryptionProvider.EncryiptionKey; completionRequest.User.Password = encryptedPassword; completionRequest.User.EncryptionKey = encryptionKey; string userId = await userRepository.Add(completionRequest.User); #region Image if (completionRequest.User.Image != null && completionRequest.User.Image.StartsWith("data:image/png;base64,")) { string path = await amazonS3ImageProvider.Add($"users/{userId}/profile.png", completionRequest.User.Image); bool saved = await userRepository.UpdateImage(userId, path); } #endregion if (!String.IsNullOrEmpty(userId)) { bool updated = await inviteRepository.CompleteInvite(completionRequest.InvitationId); actionResponse.State = updated; } } else if (invite.InviteStatus == Mdls.InviteStatus.Completed) { return(BadRequest(new DTOs.Error(ErrorResponses.INVITE_COMPLETED_EXIST))); } return(Ok(actionResponse)); }