public void SaveTaskPriority(TaskPriority taskPriority) { var sql = @" if exists(select * from TaskPrioritywhere TaskPriorityID=@TaskPriorityID) begin update TaskPriority set Label = @Label , WeightOfImportance = @WeightOfImportance where TaskPriorityID=@TaskPriorityID end else begin insert into TaskPriority( Label , WeightOfImportance )values( @Label , @WeightOfImportance ); select scope_identity() as 'TaskPriorityID' end "; using (var cmd = new SqlCommand(sql)) { cmd.Parameters.Add("@TaskPriorityID", SqlDbType.Int).Value = taskPriority.TaskPriorityID; cmd.Parameters.Add("@Label", SqlDbType.VarChar, 50).Value = taskPriority.Label; cmd.Parameters.Add("@WeightOfImportance", SqlDbType.Int).Value = taskPriority.WeightOfImportance; var id = _simpleTasks.ExecuteScalar<int>(cmd); if (taskPriority.TaskPriorityID == 0) taskPriority.TaskPriorityID = id; } }
public ActionResult SaveTaskPriority(TaskPriority item) { _service.SaveTaskPriority(item); return RedirectToAction("ListTaskPriorities"); }
public void SaveTaskPriority(TaskPriority taskPriority) { _adminRepo.SaveTaskPriority(taskPriority); }