public async Task <bool> AddProfileImage(int userID, IFormFile profileImage) { bool success; try { var image = new tbl_ProfileImage { ProfileImage = await profileImage.GetBytes(), AlternativeText = $"{CurrentUser.Details(userID).Name}'s Profile Image", CreatedDate = DateTime.Now }; int profileImageID = db.SaveProfileImage(image); db.UpdateUserProfileImage(userID, profileImageID); CurrentUser.UpdateProfileImage(userID, profileImageID); success = true; } catch (Exception e) { throw e; } return(success); }
public int SaveProfileImage(tbl_ProfileImage image) { int profileImageID; using (var connection = new SqlConnection(Configuration.ConnectionString)) { if (image.ProfileImageID == 0) { profileImageID = (int)connection.Insert(image); } else { connection.Update(image); profileImageID = image.ProfileImageID; } } return(profileImageID); }