private void EditSelectedReward() { if (dgvRewards.SelectedCells.Count > 0) { Reward reward = (Reward)dgvRewards.SelectedCells[0].OwningRow.DataBoundItem; RewardForm form = new RewardForm(reward); if (form.ShowDialog(this) == DialogResult.OK) { reward.Title = form.txtTitle.Text; reward.Description = form.txtDescription.Text; rewards.Edit(reward); DisplayReward(); DisplayEmployee(); } } }
public ActionResult Save(RewardViewModel rewardModel) { if (rewardModel != null) { if (rewardModel.ID == default(int))// add { rewardsBL.Add(rewardModel.ToReward()); } else // update { var reward = rewardModel.ToReward(); rewardsBL.Edit(reward); } } return(RedirectToAction("Index")); }