public static NovAttendances Save(NovAttendances obj, EntityState state) { if (state == EntityState.Added) { obj.AttendanceID = _container.Resolve <INovAttendancesRepository>().Insert(obj); } else { _container.Resolve <INovAttendancesRepository>().Update(obj, obj.AttendanceID); } return(obj); }
public int Insert(NovAttendances obj) { using (IDbConnection db = new SqlConnection(Helper.ConnectionString)) { if (db.State == ConnectionState.Closed) { db.Open(); } var p = new DynamicParameters(); p.Add("@Event", dbType: DbType.Int32, direction: ParameterDirection.Input, value: 3); p.Add("@AttendanceID", dbType: DbType.Int32, direction: ParameterDirection.Output); p.AddDynamicParams(new { obj.EmployeeID, obj.DepartmentID, obj.BranchID, obj.One, obj.Two, obj.Three, obj.Four, obj.Five, obj.Six, obj.Seven, obj.Eight, obj.Nine, obj.Ten, obj.Eleven, obj.Twelve, obj.Thirteen, obj.Fourteen, obj.Fifteen, obj.Sixteen, obj.Seventeen, obj.Eighteen, obj.Nineteen, obj.Twenty, obj.TwentyOne, obj.TwentyTwo, obj.TwentyThree, obj.TwentyFour, obj.TwentyFive, obj.TwentySix, obj.TwentySeven, obj.TwentyEight, obj.TwentyNine, obj.Thirty, }); db.Execute("proc_NovAttendances", p, commandType: CommandType.StoredProcedure); return(p.Get <int>("@AttendanceID")); } }