Exemple #1
0
        public static bool UpdateSchedule(ScheduleModel sched)
        {
            string sqlText = $"UPDATE Schedules SET [IdDepartment] = {sched.DepartmentId}, [Data] = '{sched.Date}', [Approved] = {((sched.Approved) ? 1 : 0)} WHERE (Id = {sched.Id})";

            int iAffected = ExecuteDMLAndGetAffectedRowCount(sqlText);

            return(iAffected > 0);
        }
Exemple #2
0
        public static bool InsertSchedule(ScheduleModel sched, out int newId)
        {
            string sqlText = $"INSERT INTO Schedules ([IdDepartment], [Data], [Approved]) VALUES ({sched.DepartmentId}, '{sched.Date}', {((sched.Approved) ? 1 : 0)}); SELECT @@IDENTITY";

            using (DBContext db = new DBContext())
            {
                newId = (int)db.ExecuteScalar(sqlText);
            }

            return(newId > 0);
        }