public static DeductionTypes Save(DeductionTypes obj, EntityState state) { if (state == EntityState.Added) { obj.DeductionTypeID = _container.Resolve <IDeductionTypesRepository>().Insert(obj); } else { _container.Resolve <IDeductionTypesRepository>().Update(obj, obj.DeductionTypeID); } return(obj); }
public bool Update(DeductionTypes obj, int DeductionTypeID) { 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("@DeductionTypesID", dbType: DbType.Int32, direction: ParameterDirection.Input, value: DeductionTypeID); p.AddDynamicParams(new { obj.Amount, obj.DeductionCode, obj.DeductionName, obj.DeductionPercentage, obj.EmployeeID }); var result = db.Execute("proc_DeductionTypes", p, commandType: CommandType.StoredProcedure); return(result != 0); } }
public int Insert(DeductionTypes obj) { using (IDbConnection db = new SqlConnection(Helper.ConnectionString)) { if (db.State == ConnectionState.Closed) { db.Open(); } var p = new DynamicParameters(); p.Add("@Event", value: 1, dbType: DbType.Int32, direction: ParameterDirection.Input); p.Add("@DeductionTypesID", dbType: DbType.Int32, direction: ParameterDirection.Output); p.AddDynamicParams(new { obj.Amount, obj.DeductionCode, obj.DeductionName, obj.DeductionPercentage, obj.EmployeeID }); db.Execute("proc_DeductionTypes", p, commandType: CommandType.StoredProcedure); return(p.Get <int>("@DeductionTypesID")); } }