public static IUser Get(string id, Role role) { using (Command cmd = new Command("get_" + role.ToEntity())) { try { IUser user = UserGateway.Get(cmd, id, role); if (user == null) throw new NotFoundBaseObjException(role.ToLabel(),id); return user; } catch (NotFoundBaseObjException) { throw; } catch { throw new NotFoundBaseObjException(role.ToLabel(), 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 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"])); } } }