private void StoreUserPhoto(User user, string photoPath, bool isPrimary) { if (photoPath.IsNotNullOrEmpty() && File.Exists(photoPath)) { try { using (var image = System.Drawing.Image.FromFile(photoPath)) { var photo = new Photo(); photo.Image = image; photo.Primary = isPrimary; photo.Approved = true; photo.Name = String.Empty; photo.Description = String.Empty; photo.User = user; photo.Save(true); if (isPrimary) Photo.SetPrimary(user.Username, photo); photo.ApprovePhoto(CurrentAdminSession.Username); } var destination = photoPath.Replace(".jpg", "v.jpg"); File.Copy(photoPath, destination); File.Delete(photoPath); } catch (Exception ex) { Log(ex); } } }