public HttpResponseMessage Put(RegisterEmployee re) { ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal; RegisterEmployeeDA.UpdateRegisterEmployee(re, p.Claims); return new HttpResponseMessage(HttpStatusCode.OK); }
public HttpResponseMessage Post(RegisterEmployee re) { ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal; int id = RegisterEmployeeDA.InsertRegisterEmployee(re, p.Claims); HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK); message.Content = new StringContent(id.ToString()); return message; }
public static RegisterEmployee GetEmployeeByRegAndEmployeeID(int regID, int emplID, IEnumerable<Claim> claims) { string sql = "SELECT * FROM Register_Employee WHERE RegisterID=@ID AND EmployeeID=@ID2"; DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", regID); DbParameter parID2 = Database.AddParameter(Database.ADMIN_DB, "@ID2", regID); DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parID, parID2); reader.Read(); RegisterEmployee re = new RegisterEmployee(); int rID = Int32.Parse(reader["RegisterID"].ToString()); int eID = Int32.Parse(reader["EmployeeID"].ToString()); re.TimeFrom = Int32.Parse(reader["FromTime"].ToString()); re.TimeTill = Int32.Parse(reader["UntilTime"].ToString()); re.EmployeeID = EmployeeDA.GetEmployeeByID(eID, claims); re.RegisterID = RegistersDA.GetRegisterByID(rID, claims); reader.Close(); return re; }
public static List<RegisterEmployee> GetRegisterEmployee(IEnumerable<Claim> claims) { List<RegisterEmployee> list = new List<RegisterEmployee>(); string sql = "SELECT * FROM Register_Employee"; DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql); while (reader.Read()) { RegisterEmployee re = new RegisterEmployee(); int rID = Int32.Parse(reader["RegisterID"].ToString()); int eID = Int32.Parse(reader["EmployeeID"].ToString()); re.TimeFrom = Int32.Parse(reader["FromTime"].ToString()); re.TimeTill = Int32.Parse(reader["UntilTime"].ToString()); re.EmployeeID = EmployeeDA.GetEmployeeByID(eID, claims); re.RegisterID = RegistersDA.GetRegisterByID(rID, claims); list.Add(re); } reader.Close(); return list; }
public static int UpdateRegisterEmployee(RegisterEmployee re, IEnumerable<Claim> claims) { string sql = "UPDATE Register_Employee SET RegisterID=@RegisterID, EmployeeID=@EmployeeID, From=@From, Until=@Until WHERE RegisterID=@ID AND EmployeeID=@ID2"; DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@RegisterID", re.RegisterID.ID); DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@EmployeeID", re.EmployeeID.ID); DbParameter par3 = Database.AddParameter(Database.ADMIN_DB, "@From", re.TimeFrom); DbParameter par4 = Database.AddParameter(Database.ADMIN_DB, "@Until", re.TimeTill); DbParameter par5 = Database.AddParameter(Database.ADMIN_DB, "@ID", re.RegisterID); DbParameter par6 = Database.AddParameter(Database.ADMIN_DB, "@ID2", re.EmployeeID); return Database.ModifyData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, par3, par4, par5, par6); }
public static int InsertRegisterEmployee(RegisterEmployee re, IEnumerable<Claim> claims) { string sql = "INSERT INTO Register_Employee VALUES(@RegisterID,@EmployeeID,@From,@Until)"; DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@RegisterID", re.RegisterID.ID); DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@EmployeeID", re.EmployeeID.ID); DbParameter par3 = Database.AddParameter(Database.ADMIN_DB, "@From", re.TimeFrom); DbParameter par4 = Database.AddParameter(Database.ADMIN_DB, "@Until", re.TimeTill); return Database.InsertData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, par3, par4); }