private void Btn_Save_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(tb_EmailAddress.Text)) { emailRepository.AddOrUpdate(new Email { Address = tb_EmailAddress.Text, ActorId = Initializer.LoggedInUser.Id, ActorType = ActorType.User }); } if (pb_Image.Image != null) { var entityImage = ((EntityImage)pb_Image.Tag); entityImageRepository.AddOrUpdate(new EntityImage { Id = entityImage?.Id ?? 0, Entity = Initializer.LoggedInUser, EntityType = EntityType.User, Image = pb_Image.Image }); } Close(); }