public static decimal createTask(tasks tasks) { using (var conn = new db_entities()) { try { conn.SP_TASK_INSERT(tasks.name, tasks.description, tasks.process_id, tasks.father_taks_id, tasks.task_status, tasks.date_start, tasks.date_end, DateTime.Now, tasks.creator_user_id, tasks.assing_id); var result = conn.tasks.Where(x => x.name == tasks.name && x.description == tasks.description && x.creator_user_id == tasks.creator_user_id).FirstOrDefault(); if (result != null) { log_task logTask = new log_task(); logTask.task_id = result.id; logTask.task_status_code = tasks.task_status; conn.log_task.Add(logTask); //conn.SaveChanges(); return(result.id); } else { return(-1); } } catch (Exception e) { throw e; } } }