public static bool Insert(IDictionary<string, object> values) { using (Command cmd = new Command("insert_Course")) { try { if(CourseGateway.Insert(cmd, values)) { cmd.Commint(); return true; } cmd.RollBack(); throw new InsertBaseObjException(Course.Label, Convert.ToString(values["Name"])); } catch (InsertBaseObjException) { throw; } catch { cmd.RollBack(); throw new InsertBaseObjException(Course.Label, Convert.ToString(values["Name"])); } } }
public static bool Insert(IDictionary<string, object> values) { if(!values.ContainsKey("Score")) values.Add("Score",null); using (Command cmd=new Command("insert_"+Selection.Entity)) { try { if( SelectionGateway.Insert(cmd, values)) { cmd.Commint(); return true; } cmd.RollBack(); throw new InsertBaseObjException(Selection.Label,Convert.ToString(values["Id"])); } catch (InsertBaseObjException) { throw; } catch { cmd.RollBack(); throw new InsertBaseObjException(Selection.Label, Convert.ToString(values["Id"])); } } }
public static bool Delete(string id) { using (Command cmd = new Command("delete_"+Selection.Entity)) { try { if (SelectionGateway.Delete(cmd, id)) { cmd.Commint(); return true; } cmd.RollBack(); throw new DeleteBaseObjException(Selection.Label, id); } catch (DeleteBaseObjException) { throw; } catch { cmd.RollBack(); throw new DeleteBaseObjException(Selection.Label, id); } } }
public static bool Delete(string id) { using (Command cmd = new Command("delete_Course")) { try { bool result = CourseGateway.Delete(cmd, id); if (!result) throw new DeleteBaseObjException(Course.Label, id); cmd.Commint(); return true; } catch (DeleteBaseObjException) { cmd.RollBack(); throw; } catch { cmd.RollBack(); throw new DeleteBaseObjException(Course.Label, id); } } }
public static bool Delete(Role role, string id) { using (Command cmd = new Command("delete_" + role.ToEntity())) { try { bool result = UserGateway.Delete(cmd, role, id); if (!result) throw new DeleteBaseObjException(role.ToLabel(), id); cmd.Commint(); return true; } catch (DeleteBaseObjException) { cmd.RollBack(); throw; } catch { cmd.RollBack(); throw new DeleteBaseObjException(role.ToLabel(), id); } } }
public static IUser Authenticate(string id, string pwd, Role role) { using (Command cmd = new Command("auth")) { try { IUser user = UserGateway.Authenticate(cmd, id, pwd, role); if (user == null) throw new FailAuthException(); cmd.Commint(); return user; } catch (AuthenticationException) { cmd.RollBack(); throw; } catch { cmd.RollBack(); throw new FailAuthException(); } } }
public static bool Update(IDictionary<string,object> values ) { using (Command cmd = new Command("update_" + Selection.Entity)) { try { return SelectionGateway.Update(cmd, values); } catch { cmd.RollBack(); return false; } } }
public static bool Update(string courseId, string studentId, int score) { ISelection target = Get(courseId, studentId); using (Command cmd=new Command("update_"+Selection.Entity)) { try { IDictionary<string,object> values=new Dictionary<string, object>(); values.Add("Score",score); values.Add("oId",target.Id); return SelectionGateway.Update(cmd, values); } catch { cmd.RollBack(); return false; } } }
public static bool Update(Role role, IDictionary<string, object> values) { using (Command cmd = new Command("update_" + role.ToEntity())) { try { if (UserGateway.Update(cmd, role, values)) { cmd.Commint(); return true; } cmd.RollBack(); throw new UpdateBaseObjException(role.ToLabel(), Convert.ToString(values["Id"])); } catch (UpdateBaseObjException) { throw; } catch { cmd.RollBack(); throw new UpdateBaseObjException(role.ToLabel(), Convert.ToString(values["Id"])); } } }
public static bool ResetPwd(Role role,string id, string pwd) { using (Command cmd = new Command("resetPwd_" + role.ToEntity())) { try { IDictionary<string,object> values=new Dictionary<string, object>() { {"Password",pwd}, {"oId",id} }; if (UserGateway.Update(cmd, role, values)) { cmd.Commint(); return true; } else { cmd.RollBack(); return false; } } catch { cmd.RollBack(); return false; } } }